Fix painless return type cast for list shortcut (#126724)

This fixes an issue where if a Painless getter method return type
 didn't match a Java getter method return type we add a cast. 
Currentlythis is adding an extraneous cast.

Closes: #70682
This commit is contained in:
Jack Conradson 2025-04-11 13:50:19 -07:00 committed by GitHub
parent 9d18d5280a
commit c1ecafad6a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View file

@ -0,0 +1,5 @@
pr: 126724
summary: Fix painless return type cast for list shortcut
area: Infra/Scripting
type: bug
issues: []

View file

@ -1465,7 +1465,7 @@ public class DefaultIRTreeToASMBytesPhase implements IRTreeVisitor<WriteScope> {
PainlessMethod getterPainlessMethod = irDotSubShortcutNode.getDecorationValue(IRDMethod.class);
methodWriter.invokeMethodCall(getterPainlessMethod);
if (getterPainlessMethod.returnType().equals(getterPainlessMethod.javaMethod().getReturnType()) == false) {
if (getterPainlessMethod.returnType() != getterPainlessMethod.javaMethod().getReturnType()) {
methodWriter.checkCast(MethodWriter.getType(getterPainlessMethod.returnType()));
}
}
@ -1478,7 +1478,7 @@ public class DefaultIRTreeToASMBytesPhase implements IRTreeVisitor<WriteScope> {
PainlessMethod getterPainlessMethod = irLoadListShortcutNode.getDecorationValue(IRDMethod.class);
methodWriter.invokeMethodCall(getterPainlessMethod);
if (getterPainlessMethod.returnType() == getterPainlessMethod.javaMethod().getReturnType()) {
if (getterPainlessMethod.returnType() != getterPainlessMethod.javaMethod().getReturnType()) {
methodWriter.checkCast(MethodWriter.getType(getterPainlessMethod.returnType()));
}
}