You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by jo...@apache.org on 2025/07/22 14:07:53 UTC

(groovy) branch GROOVY-11719-regression-semantic-analysis-exception created (now d5acd7d1a8)

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

jonnybot pushed a change to branch GROOVY-11719-regression-semantic-analysis-exception
in repository https://gitbox.apache.org/repos/asf/groovy.git


      at d5acd7d1a8 Add test for generics handling

This branch includes the following new commits:

     new 4eb5a76804 Revert "GROOVY-11711: restore outer class generics after inner class visit"
     new d5acd7d1a8 Add test for generics handling

The 2 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/02: Revert "GROOVY-11711: restore outer class generics after inner class visit"

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

jonnybot pushed a commit to branch GROOVY-11719-regression-semantic-analysis-exception
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 4eb5a76804af1a75f8640058988ead1351a037e6
Author: Jonny Carter <jc...@adaptavist.com>
AuthorDate: Tue Jul 22 09:04:16 2025 -0500

    Revert "GROOVY-11711: restore outer class generics after inner class visit"
    
    This reverts commit 33064484cc043bfb7c2ad75ee8fccbcbc6329b76.
---
 .../org/codehaus/groovy/control/ResolveVisitor.java   |  9 +--------
 src/test/groovy/gls/innerClass/InnerClassTest.groovy  | 19 -------------------
 2 files changed, 1 insertion(+), 27 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java b/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java
index 383c0bffa7..1af01a97d9 100644
--- a/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java
+++ b/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java
@@ -1272,14 +1272,8 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
 
         //
 
-        Map<GenericsTypeName, GenericsType> outerNames = null;
-        if (node instanceof InnerClassNode) {
-            outerNames = genericParameterNames;
+        if (!(node instanceof InnerClassNode) || Modifier.isStatic(node.getModifiers())) {
             genericParameterNames = new HashMap<>();
-            if (!Modifier.isStatic(node.getModifiers()))
-                genericParameterNames.putAll(outerNames); // outer names visible
-        } else {
-            genericParameterNames.clear(); // outer class: new generic namespace
         }
         resolveGenericsHeader(node.getGenericsTypes());
         switch (phase) { // GROOVY-9866, GROOVY-10466
@@ -1322,7 +1316,6 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
             visitObjectInitializerStatements(node);
             visitAnnotations(node); // GROOVY-10750, GROOVY-11206
         }
-        if (outerNames != null) genericParameterNames = outerNames;
         currentClass = oldNode;
     }
 
diff --git a/src/test/groovy/gls/innerClass/InnerClassTest.groovy b/src/test/groovy/gls/innerClass/InnerClassTest.groovy
index 4378c49efa..148a562bea 100644
--- a/src/test/groovy/gls/innerClass/InnerClassTest.groovy
+++ b/src/test/groovy/gls/innerClass/InnerClassTest.groovy
@@ -1265,25 +1265,6 @@ final class InnerClassTest {
         assert err =~ /No enclosing instance passed in constructor call of a non-static inner class/
     }
 
-    // GROOVY-11711
-    @Test
-    void testUsageOfOuterType6() {
-        assertScript '''
-            class Foo<T> {
-                static class Bar {
-                }
-                /*non-static*/ class Baz
-                    implements java.util.concurrent.Callable<T> {
-                    T call() {
-                    }
-                }
-            }
-            def foo = new Foo<Short>()
-            def baz = new Foo.Baz(foo)
-            assert baz.call() == null
-        '''
-    }
-
     @Test
     void testClassOutputOrdering() {
         // this does actually not do much, but before this


(groovy) 02/02: Add test for generics handling

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

jonnybot pushed a commit to branch GROOVY-11719-regression-semantic-analysis-exception
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit d5acd7d1a809e6c991fc3f50c00a6ea87ae84a1b
Author: Jonny Carter <jc...@adaptavist.com>
AuthorDate: Tue Jul 22 09:04:27 2025 -0500

    Add test for generics handling
    
    GROOVY-11719
---
 .../util/GroovyScriptEngineReloadingTest.groovy    | 33 ++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/src/test/groovy/groovy/util/GroovyScriptEngineReloadingTest.groovy b/src/test/groovy/groovy/util/GroovyScriptEngineReloadingTest.groovy
index 660f4ddcf0..935d99abc8 100644
--- a/src/test/groovy/groovy/util/GroovyScriptEngineReloadingTest.groovy
+++ b/src/test/groovy/groovy/util/GroovyScriptEngineReloadingTest.groovy
@@ -182,6 +182,39 @@ final class GroovyScriptEngineReloadingTest {
 
     }
 
+    @Test
+    void testRecompilingWithGenericsAndConstants() {
+        MapFileSystem.instance.modFile('BaseClass.groovy', 'class BaseClass<T> {}', gse.@time)
+
+        def tertiaryClassText = '''
+            class NotGeneric {
+                /**
+                 * Not typed on purpose - if typed as String then NotGeneric is no longer a dependency of
+                 * ParameterisedClass for some reason...
+                 */
+                public static final Object CONSTANT = "not generic"
+            }
+        '''
+        MapFileSystem.instance.modFile('NotGeneric.groovy', tertiaryClassText, gse.@time)
+
+        def subClassText = '''
+            class SubClass extends BaseClass<String> {
+                public static final String CONSTANT = NotGeneric.CONSTANT
+            }
+        '''
+        MapFileSystem.instance.modFile('SubClass.groovy', subClassText, gse.@time)
+
+        MapFileSystem.instance.modFile('scriptUsingGeneric.groovy', 'SubClass.CONSTANT', gse.@time)
+
+
+        gse.loadScriptByName('scriptUsingGeneric.groovy')
+        sleep 1000
+
+        // make a change to the sub-class so that it gets recompiled
+        MapFileSystem.instance.modFile('SubClass.groovy', subClassText + '\n', gse.@time)
+        gse.loadScriptByName('scriptUsingGeneric.groovy')
+    }
+
     @Test
     void testDeleteDependent() {
         sleep 10000