You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by em...@apache.org on 2021/06/16 20:14:27 UTC

[groovy] branch GROOVY-10141 created (now 22d3c2e)

This is an automated email from the ASF dual-hosted git repository.

emilles pushed a change to branch GROOVY-10141
in repository https://gitbox.apache.org/repos/asf/groovy.git.


      at 22d3c2e  GROOVY-10141: retain parse order of anon. inner types in module classes

This branch includes the following new commits:

     new 22d3c2e  GROOVY-10141: retain parse order of anon. inner types in module classes

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[groovy] 01/01: GROOVY-10141: retain parse order of anon. inner types in module classes

Posted by em...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

emilles pushed a commit to branch GROOVY-10141
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 22d3c2e6d6fa3608abdd2213617c9de642412569
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Wed Jun 16 15:14:02 2021 -0500

    GROOVY-10141: retain parse order of anon. inner types in module classes
    
    - InnerClassVisitor checks this$0 which isn't set up if C$1$1 before C$1
---
 .../org/apache/groovy/parser/antlr4/AstBuilder.java  |  3 +--
 src/test/gls/innerClass/InnerClassTest.groovy        | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
index 9801be9..3505867 100644
--- a/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
+++ b/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
@@ -3250,14 +3250,13 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> {
         anonymousInnerClass.setAnonymous(true);
         anonymousInnerClass.putNodeMetaData(CLASS_NAME, innerClassName);
         configureAST(anonymousInnerClass, ctx);
+        classNodeList.add(anonymousInnerClass);
 
         classNodeStack.push(anonymousInnerClass);
         ctx.classBody().putNodeMetaData(CLASS_DECLARATION_CLASS_NODE, anonymousInnerClass);
         this.visitClassBody(ctx.classBody());
         classNodeStack.pop();
 
-        classNodeList.add(anonymousInnerClass);
-
         return anonymousInnerClass;
     }
 
diff --git a/src/test/gls/innerClass/InnerClassTest.groovy b/src/test/gls/innerClass/InnerClassTest.groovy
index c13cc5a..c879798 100644
--- a/src/test/gls/innerClass/InnerClassTest.groovy
+++ b/src/test/gls/innerClass/InnerClassTest.groovy
@@ -1758,6 +1758,26 @@ final class InnerClassTest {
         '''
     }
 
+    @Test // GROOVY-10141
+    void testInnerClassIn2xAIC() {
+        assertScript '''
+            class Outer {
+                class Inner {
+                }
+                def obj = new Object() {
+                    String toString() {
+                        new Object() {
+                            String toString() {
+                                new Inner()
+                            }
+                        }
+                    }
+                }
+            }
+            new Outer().obj.toString()
+        '''
+    }
+
     @Test // GROOVY-8274
     void testMissingMethodHandling() {
         assertScript '''