-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add dynamic (duck) type resolution to Painless static types #78575
Conversation
Pinging @elastic/es-core-infra (Team:Core/Infra) |
@@ -2904,34 +2943,12 @@ public void visitCall(ECall userCallNode, SemanticScope semanticScope) { | |||
} | |||
|
|||
TargetType targetType = userCallNode.isNullSafe() ? null : semanticScope.getDecoration(userCallNode, TargetType.class); | |||
// TODO: remove ZonedDateTime exception when JodaCompatibleDateTime is removed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JodaCompatibleDateTime
was this missed in #78417?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! I searched for the class usages as opposed to just the name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very clean
@stu-elastic Thanks for the review! |
This change adds dynamic (duck) type resolution to Painless static types using an annotation ( at dynamic_type ) to control which static types are allowed to be dynamically invoked. This annotation does not chain so any sub classes that also require dynamic type resolution must be annotated as well.
This change adds dynamic (duck) type resolution to Painless static types using an annotation ( at dynamic_type ) to control which static types are allowed to be dynamically invoked. This annotation does not chain so any sub classes that also require dynamic type resolution must be annotated as well.
Example:
Normally, this would fail as
a
is statically typed, so the method duck would not be found. With dynamic type resolution, this will succeed by seeing that we have a possible duck method on a sub class and binding the method at runtime instead.