The setter shortcut resolution worked for bridged setter methods, in `PainlessLookupBuilder.cacheRuntimeHandles`, but did not work for other setters.
@@ -0,0 +1,5 @@
+pr: 86868
+summary: "Script: Fix setter shortcut for unbridged setters"
+area: Infra/Scripting
+type: bug
+issues: []
@@ -2880,7 +2880,7 @@ public class DefaultSemanticAnalysisPhase extends UserTreeBaseVisitor<SemanticSc
prefixType,
isStatic,
"set" + Character.toUpperCase(index.charAt(0)) + index.substring(1),
- 0
+ 1
);
if (getter != null || setter != null) {
@@ -167,6 +167,16 @@ public class BasicAPITests extends ScriptTestCase {
}
+ public void testSetterShortcut() {
+ assertEquals(
+ 25,
+ exec(
+ "org.elasticsearch.painless.FeatureTestObject ft = new org.elasticsearch.painless.FeatureTestObject();"
+ + "ft.y = 25; return ft.y;"
+ )
+ );
+ }
+
public void testNoSemicolon() {
assertEquals(true, exec("def x = true; if (x) return x"));