diff --git a/docs/changelog/126724.yaml b/docs/changelog/126724.yaml new file mode 100644 index 0000000000000..8c41d04ff7ae5 --- /dev/null +++ b/docs/changelog/126724.yaml @@ -0,0 +1,5 @@ +pr: 126724 +summary: Fix painless return type cast for list shortcut +area: Infra/Scripting +type: bug +issues: [] diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/phase/DefaultIRTreeToASMBytesPhase.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/phase/DefaultIRTreeToASMBytesPhase.java index 04d74882f54ae..4ab0af644505c 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/phase/DefaultIRTreeToASMBytesPhase.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/phase/DefaultIRTreeToASMBytesPhase.java @@ -1465,7 +1465,7 @@ public void visitLoadDotShortcut(LoadDotShortcutNode irDotSubShortcutNode, Write 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 void visitLoadListShortcut(LoadListShortcutNode irLoadListShortcutNode, W 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())); } }