File tree Expand file tree Collapse file tree
main/java/org/openrewrite/groovy
test/java/org/openrewrite/groovy/tree Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2530,6 +2530,11 @@ public void visitTupleExpression(TupleExpression tuple) {
25302530
25312531 List <JRightPadded <Expression >> args = new ArrayList <>(tuple .getExpressions ().size ());
25322532 for (org .codehaus .groovy .ast .expr .Expression expression : tuple .getExpressions ()) {
2533+ // Skip synthetic args (e.g. the implicit outer-`this` Groovy adds when
2534+ // constructing a non-static inner class from within the enclosing class)
2535+ if (!appearsInSource (expression )) {
2536+ continue ;
2537+ }
25332538 NamedArgumentListExpression namedArgList = (NamedArgumentListExpression ) expression ;
25342539 List <MapEntryExpression > mapEntryExpressions = namedArgList .getMapEntryExpressions ();
25352540 for (int i = 0 ; i < mapEntryExpressions .size (); i ++) {
Original file line number Diff line number Diff line change @@ -151,6 +151,20 @@ class T {
151151 );
152152 }
153153
154+ @ Test
155+ void nonStaticInnerClassNamedArgs () {
156+ rewriteRun (
157+ groovy (
158+ """
159+ class T {
160+ class Reader { }
161+ def m() { new Reader(a: 1) }
162+ }
163+ """
164+ )
165+ );
166+ }
167+
154168 @ Test
155169 void innerClassConstructorWithOnlySuperCall () {
156170 rewriteRun (
You can’t perform that action at this time.
0 commit comments