-
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
[Painless] Partially fixes def boxed types casting #35563
Conversation
Pinging @elastic/es-core-infra |
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.
Looks fine, just one question.
public static Byte defToByteExplicit(final Object value) { | ||
if (value == null) { | ||
return null; | ||
} else if (value instanceof Character) { |
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.
I thought byte -> char and char -> byte had to be explicit (in java). Does painless differ here?
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.
Good catch, you are correct. This is a bug that I'll fix now.
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.
Note this is the explicit version, though. I corrected the implicit versions.
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.
LGTM
@rjernst Thanks for the review! Will commit as soon as CI passes. |
I'm closing this in favor of the quick/easier fix for now (#35653). The casting model in Painless needs to be revisited in a separate follow up as some of the specced out casts do not work as expected, but the fixes need to be given more thought so more problems are not created. |
An issue related to implicitly casting to appropriate return types was revealed (#35351). According to the Painless spec (https://www.elastic.co/guide/en/elasticsearch/painless/current/painless-casting.html), def values are allowed to implicitly cast from one boxed type to another boxed type such as
Integer
toDouble
. Currently, this not working according to spec. This partially fixes the issue by inserting appropriate methods at compile-time to execute the casts at run-time. The other part of the issue will be a different PR as it needs to fix an issue related to boxing for method parameters at run-time which is trickier due to run-time code path.