From 6014acf8c0994249811e23345e62882a5f5386b3 Mon Sep 17 00:00:00 2001 From: Jack Conradson Date: Fri, 11 Apr 2025 12:26:57 -0700 Subject: [PATCH 1/2] fix painless return type cast for list shortcut --- .../painless/phase/DefaultIRTreeToASMBytesPhase.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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())); } } From 0b60423857c0e66d43b1c0027426d82f78b45ac0 Mon Sep 17 00:00:00 2001 From: Jack Conradson Date: Fri, 11 Apr 2025 12:36:28 -0700 Subject: [PATCH 2/2] Update docs/changelog/126724.yaml --- docs/changelog/126724.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 docs/changelog/126724.yaml 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: []