You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by GitBox <gi...@apache.org> on 2022/03/05 00:21:42 UTC

[GitHub] [groovy] eric-milles opened a new pull request #1698: GROOVY-9866, GROOVY-10466: resolve all class headers before class bodies

eric-milles opened a new pull request #1698:
URL: https://github.com/apache/groovy/pull/1698


   Solve order issue by resolving all class headers before resolving class bodies (incl. `VariableScopeVisitor` application).  `ResolveVisitor#visitClass` is split into phases.  I chose not to refactor into separate methods to keep the change smaller and keep the external API pretty much the same.  `CompilationUnit` indicates which phase (1=head 2=body) to execute.  There is some overlap to preserve generics resolution for inner types.
   
   https://issues.apache.org/jira/browse/GROOVY-10466
   https://issues.apache.org/jira/browse/GROOVY-9866


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [groovy] lptr commented on pull request #1698: GROOVY-9866, GROOVY-10466: resolve all class headers before class bodies

Posted by GitBox <gi...@apache.org>.
lptr commented on pull request #1698:
URL: https://github.com/apache/groovy/pull/1698#issuecomment-1060755491


   Can you publish a snapshot with these changes please? I'd like to run it on Gradle. Alternatively, please try to run `./gradlew compileAll` on this brach: https://github.com/gradle/gradle/pull/20038.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [groovy] sonatype-lift[bot] commented on a change in pull request #1698: GROOVY-9866, GROOVY-10466: resolve all class headers before class bodies

Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on a change in pull request #1698:
URL: https://github.com/apache/groovy/pull/1698#discussion_r820013211



##########
File path: src/main/java/org/codehaus/groovy/control/ResolveVisitor.java
##########
@@ -1316,46 +1316,50 @@ public void visitClass(final ClassNode node) {
             genericParameterNames = new HashMap<>();
         }
         resolveGenericsHeader(node.getGenericsTypes());
+        switch (phase) { // GROOVY-9866, GROOVY-10466
+          case 0:
+          case 1:
+            ClassNode sn = node.getUnresolvedSuperClass();
+            if (sn != null) {
+                resolveOrFail(sn, "", node, true);
+            }
+            for (ClassNode in : node.getInterfaces()) {
+                resolveOrFail(in, "", node, true);
+            }
 
-        ClassNode sn = node.getUnresolvedSuperClass();
-        if (sn != null) {
-            resolveOrFail(sn, "", node, true);
-        }
-        for (ClassNode in : node.getInterfaces()) {
-            resolveOrFail(in, "", node, true);
-        }
-
-        if (sn != null) checkCyclicInheritance(node, sn);
-        for (ClassNode in : node.getInterfaces()) {
-            checkCyclicInheritance(node, in);
-        }
-        if (node.getGenericsTypes() != null) {
-            for (GenericsType gt : node.getGenericsTypes()) {
-                if (gt != null && gt.getUpperBounds() != null) {
-                    for (ClassNode variant : gt.getUpperBounds()) {
-                        if (variant.isGenericsPlaceHolder()) checkCyclicInheritance(variant, gt.getType());
+            if (sn != null) checkCyclicInheritance(node, sn);
+            for (ClassNode in : node.getInterfaces()) {
+                checkCyclicInheritance(node, in);
+            }
+            if (node.getGenericsTypes() != null) {
+                for (GenericsType gt : node.getGenericsTypes()) {
+                    if (gt != null && gt.getUpperBounds() != null) {
+                        for (ClassNode variant : gt.getUpperBounds()) {
+                            if (variant.isGenericsPlaceHolder()) checkCyclicInheritance(variant, gt.getType());
+                        }
                     }
                 }
             }
-        }
-
-        // VariableScopeVisitor visits anon. inner class body inline, so resolve now
-        for (Iterator<InnerClassNode> it = node.getInnerClasses(); it.hasNext(); ) {
-            InnerClassNode cn = it.next();
-            if (cn.isAnonymous()) {
-                MethodNode enclosingMethod = cn.getEnclosingMethod();
-                if (enclosingMethod != null) {
-                    resolveGenericsHeader(enclosingMethod.getGenericsTypes()); // GROOVY-6977
+          case 2:

Review comment:
       I've recorded this as ignored for this pull request. If you change your mind, just comment `@sonatype-lift unignore`.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [groovy] paulk-asert commented on pull request #1698: GROOVY-9866, GROOVY-10466: resolve all class headers before class bodies

Posted by GitBox <gi...@apache.org>.
paulk-asert commented on pull request #1698:
URL: https://github.com/apache/groovy/pull/1698#issuecomment-1060626763


   That isn't the current plan. One day left in voting window for 4.0.1. We can do a 4.0.2 fairly quickly if we need to but it would be good to do further testing once this is merged into the 4_0_X (and master) branches including some performance testing. We can do that in parallel with snapshot builds. There are likely a few more fixes we'd like in a 4.0.2 that we would also like to get out fairly quickly but there are already some quite important fixes in 4.0.1 that we don't really want to delay.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [groovy] lptr commented on pull request #1698: GROOVY-9866, GROOVY-10466: resolve all class headers before class bodies

Posted by GitBox <gi...@apache.org>.
lptr commented on pull request #1698:
URL: https://github.com/apache/groovy/pull/1698#issuecomment-1061648570


   I don't think I can consume snapshots directly from GitHub like that. But the test seems to be passing now, so I'd say it looks good to merge, and then I can test the resulting snapshot on the official snapshot repo once it's published.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [groovy] leonard84 commented on pull request #1698: GROOVY-9866, GROOVY-10466: resolve all class headers before class bodies

Posted by GitBox <gi...@apache.org>.
leonard84 commented on pull request #1698:
URL: https://github.com/apache/groovy/pull/1698#issuecomment-1060530526


   Will this make it into 4.0.1 ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [groovy] eric-milles merged pull request #1698: GROOVY-9866, GROOVY-10466: resolve all class headers before class bodies

Posted by GitBox <gi...@apache.org>.
eric-milles merged pull request #1698:
URL: https://github.com/apache/groovy/pull/1698


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [groovy] paulk-asert commented on pull request #1698: GROOVY-9866, GROOVY-10466: resolve all class headers before class bodies

Posted by GitBox <gi...@apache.org>.
paulk-asert commented on pull request #1698:
URL: https://github.com/apache/groovy/pull/1698#issuecomment-1060251441


   +1


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [groovy] sonatype-lift[bot] commented on a change in pull request #1698: GROOVY-9866, GROOVY-10466: resolve all class headers before class bodies

Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on a change in pull request #1698:
URL: https://github.com/apache/groovy/pull/1698#discussion_r820010850



##########
File path: src/main/java/org/codehaus/groovy/control/ResolveVisitor.java
##########
@@ -1316,46 +1316,50 @@ public void visitClass(final ClassNode node) {
             genericParameterNames = new HashMap<>();
         }
         resolveGenericsHeader(node.getGenericsTypes());
+        switch (phase) { // GROOVY-9866, GROOVY-10466
+          case 0:
+          case 1:
+            ClassNode sn = node.getUnresolvedSuperClass();
+            if (sn != null) {
+                resolveOrFail(sn, "", node, true);
+            }
+            for (ClassNode in : node.getInterfaces()) {
+                resolveOrFail(in, "", node, true);
+            }
 
-        ClassNode sn = node.getUnresolvedSuperClass();
-        if (sn != null) {
-            resolveOrFail(sn, "", node, true);
-        }
-        for (ClassNode in : node.getInterfaces()) {
-            resolveOrFail(in, "", node, true);
-        }
-
-        if (sn != null) checkCyclicInheritance(node, sn);
-        for (ClassNode in : node.getInterfaces()) {
-            checkCyclicInheritance(node, in);
-        }
-        if (node.getGenericsTypes() != null) {
-            for (GenericsType gt : node.getGenericsTypes()) {
-                if (gt != null && gt.getUpperBounds() != null) {
-                    for (ClassNode variant : gt.getUpperBounds()) {
-                        if (variant.isGenericsPlaceHolder()) checkCyclicInheritance(variant, gt.getType());
+            if (sn != null) checkCyclicInheritance(node, sn);
+            for (ClassNode in : node.getInterfaces()) {
+                checkCyclicInheritance(node, in);
+            }
+            if (node.getGenericsTypes() != null) {
+                for (GenericsType gt : node.getGenericsTypes()) {
+                    if (gt != null && gt.getUpperBounds() != null) {
+                        for (ClassNode variant : gt.getUpperBounds()) {
+                            if (variant.isGenericsPlaceHolder()) checkCyclicInheritance(variant, gt.getType());
+                        }
                     }
                 }
             }
-        }
-
-        // VariableScopeVisitor visits anon. inner class body inline, so resolve now
-        for (Iterator<InnerClassNode> it = node.getInnerClasses(); it.hasNext(); ) {
-            InnerClassNode cn = it.next();
-            if (cn.isAnonymous()) {
-                MethodNode enclosingMethod = cn.getEnclosingMethod();
-                if (enclosingMethod != null) {
-                    resolveGenericsHeader(enclosingMethod.getGenericsTypes()); // GROOVY-6977
+          case 2:

Review comment:
       *FallThrough:*  Execution may fall through from the previous case; add a `// fall through` comment before this line if it was deliberate [(details)](https://errorprone.info/bugpattern/FallThrough)
   (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [groovy] eric-milles commented on a change in pull request #1698: GROOVY-9866, GROOVY-10466: resolve all class headers before class bodies

Posted by GitBox <gi...@apache.org>.
eric-milles commented on a change in pull request #1698:
URL: https://github.com/apache/groovy/pull/1698#discussion_r820013195



##########
File path: src/main/java/org/codehaus/groovy/control/ResolveVisitor.java
##########
@@ -1316,46 +1316,50 @@ public void visitClass(final ClassNode node) {
             genericParameterNames = new HashMap<>();
         }
         resolveGenericsHeader(node.getGenericsTypes());
+        switch (phase) { // GROOVY-9866, GROOVY-10466
+          case 0:
+          case 1:
+            ClassNode sn = node.getUnresolvedSuperClass();
+            if (sn != null) {
+                resolveOrFail(sn, "", node, true);
+            }
+            for (ClassNode in : node.getInterfaces()) {
+                resolveOrFail(in, "", node, true);
+            }
 
-        ClassNode sn = node.getUnresolvedSuperClass();
-        if (sn != null) {
-            resolveOrFail(sn, "", node, true);
-        }
-        for (ClassNode in : node.getInterfaces()) {
-            resolveOrFail(in, "", node, true);
-        }
-
-        if (sn != null) checkCyclicInheritance(node, sn);
-        for (ClassNode in : node.getInterfaces()) {
-            checkCyclicInheritance(node, in);
-        }
-        if (node.getGenericsTypes() != null) {
-            for (GenericsType gt : node.getGenericsTypes()) {
-                if (gt != null && gt.getUpperBounds() != null) {
-                    for (ClassNode variant : gt.getUpperBounds()) {
-                        if (variant.isGenericsPlaceHolder()) checkCyclicInheritance(variant, gt.getType());
+            if (sn != null) checkCyclicInheritance(node, sn);
+            for (ClassNode in : node.getInterfaces()) {
+                checkCyclicInheritance(node, in);
+            }
+            if (node.getGenericsTypes() != null) {
+                for (GenericsType gt : node.getGenericsTypes()) {
+                    if (gt != null && gt.getUpperBounds() != null) {
+                        for (ClassNode variant : gt.getUpperBounds()) {
+                            if (variant.isGenericsPlaceHolder()) checkCyclicInheritance(variant, gt.getType());
+                        }
                     }
                 }
             }
-        }
-
-        // VariableScopeVisitor visits anon. inner class body inline, so resolve now
-        for (Iterator<InnerClassNode> it = node.getInnerClasses(); it.hasNext(); ) {
-            InnerClassNode cn = it.next();
-            if (cn.isAnonymous()) {
-                MethodNode enclosingMethod = cn.getEnclosingMethod();
-                if (enclosingMethod != null) {
-                    resolveGenericsHeader(enclosingMethod.getGenericsTypes()); // GROOVY-6977
+          case 2:

Review comment:
       @sonatype-lift ignore




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [groovy] paulk-asert commented on pull request #1698: GROOVY-9866, GROOVY-10466: resolve all class headers before class bodies

Posted by GitBox <gi...@apache.org>.
paulk-asert commented on pull request #1698:
URL: https://github.com/apache/groovy/pull/1698#issuecomment-1060797757


   @lptr Does this work for you:
   https://github.com/apache/groovy/actions/runs/1936513664


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org