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

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

commit a36ae26ff95b610749176b2034e129ee699f9ad1
Author: Eric Milles <[email protected]>
AuthorDate: Mon Feb 2 10:43:20 2026 -0600

    next step
---
 src/main/java/groovy/lang/MetaClassImpl.java       | 124 ++++-----
 .../groovy/classgen/EnumCompletionVisitor.java     |  51 ----
 .../classgen/InnerClassCompletionVisitor.java      |   4 +-
 .../groovy/gls/innerClass/InnerClassTest.groovy    | 147 ++++++++++-
 src/test/groovy/groovy/ClosureTest.groovy          | 285 ++++++++-------------
 src/test/groovy/groovy/PropertyTest.groovy         |  18 --
 .../packageScope/PackageScopeTransformTest.groovy  |   4 +-
 7 files changed, 318 insertions(+), 315 deletions(-)

diff --git a/src/main/java/groovy/lang/MetaClassImpl.java 
b/src/main/java/groovy/lang/MetaClassImpl.java
index 6df885bcb3..7f88b8314d 100644
--- a/src/main/java/groovy/lang/MetaClassImpl.java
+++ b/src/main/java/groovy/lang/MetaClassImpl.java
@@ -1217,7 +1217,29 @@ public class MetaClassImpl implements MetaClass, 
MutableMetaClass {
             return transformedMetaMethod.doMethodInvoke(object, arguments);
         }
 
-        return invokePropertyOrMissing(sender, object, methodName, 
originalArguments, fromInsideClass, isCallToSuper);
+        try {
+            return invokePropertyOrMissing(sender, object, methodName, 
originalArguments, fromInsideClass, isCallToSuper);
+        } catch (MissingMethodException mme) {
+            if (!isCallToSuper) {
+                return invokeOuterMethod(sender, object, methodName, 
originalArguments, mme); // GROOVY-11823
+            }
+            throw mme;
+        }
+    }
+
+    private Object invokeOuterMethod(final Class<?> sender, final Object 
object, final String methodName, final Object[] arguments, final 
MissingMethodException mme) {
+        if (sender == theClass ? isGroovyObject() : 
GroovyObject.class.isAssignableFrom(sender)) {
+            var outerClass = sender.getEnclosingClass(); // check outer class 
nesting of call site
+            if (outerClass != null && (sender == theClass || 
sender.isAssignableFrom(theClass))) {
+                MetaClass omc = registry.getMetaClass(outerClass);
+                try {
+                    return omc.invokeMethod(outerClass, outerClass, 
methodName, arguments, false, false);
+                } catch (MissingMethodException e) {
+                    mme.addSuppressed(e);
+                }
+            }
+        }
+        throw mme;
     }
 
     private MetaMethod getMetaMethod(final Class<?> sender, final Object 
object, final String methodName, final boolean isCallToSuper, final Object[] 
arguments) {
@@ -1894,28 +1916,7 @@ public class MetaClassImpl implements MetaClass, 
MutableMetaClass {
         try {
             return invokeMissingProperty(object, name, null, true);
         } catch (MissingPropertyException mpe) {
-            if (false && sender == theClass) {
-                Class<?> outerClass = theClass.getEnclosingClass();
-                if (outerClass != null) {
-                    MetaClass omc = registry.getMetaClass(outerClass);
-                    try {
-                        Object outer = outerClass;
-                        if ((theClass.getModifiers() & Opcodes.ACC_STATIC) == 
0) {
-                            try {
-                                theClass.getDeclaredField("this$0");
-                                outer = getAttribute(object, "this$0");
-                            } catch (NoSuchFieldException e) {
-                            }
-                        }
-                        return omc.getProperty(outerClass, outer, name, false, 
false);
-                    } catch (MissingPropertyException suppressed) {
-                        mpe.addSuppressed(suppressed);
-                    } catch (Throwable t) {
-                        t.printStackTrace();
-                    }
-                }
-            }
-            throw mpe;
+            return getOuterProperty(sender, object, name, mpe);
         }
     }
 
@@ -1945,6 +1946,21 @@ public class MetaClassImpl implements MetaClass, 
MutableMetaClass {
         }
     }
 
+    private Object getOuterProperty(final Class<?> sender, final Object 
object, final String name, final MissingPropertyException mpe) {
+        if (sender == theClass ? isGroovyObject() : 
GroovyObject.class.isAssignableFrom(sender)) {
+            var outerClass = sender.getEnclosingClass(); // check outer class 
nesting of call site
+            if (outerClass != null && (sender == theClass || 
sender.isAssignableFrom(theClass))) {
+                MetaClass omc = registry.getMetaClass(outerClass);
+                try {
+                    return omc.getProperty(outerClass, outerClass, name, 
false, false);
+                } catch (MissingPropertyException e) {
+                    mpe.addSuppressed(e);
+                }
+            }
+        }
+        throw mpe;
+    }
+
     public MetaProperty getEffectiveGetMetaProperty(final Class sender, final 
Object object, final String name, final boolean useSuper) {
 
         
//----------------------------------------------------------------------
@@ -2073,28 +2089,7 @@ public class MetaClassImpl implements MetaClass, 
MutableMetaClass {
                 try {
                     return invokeMissingProperty(receiver, getName(), null, 
true);
                 } catch (MissingPropertyException mpe) {
-                    if (false && sender == theClass) {
-                        Class<?> outerClass = theClass.getEnclosingClass();
-                        if (outerClass != null) {
-                            MetaClass omc = registry.getMetaClass(outerClass);
-                            try {
-                                Object outer = outerClass;
-                                if ((theClass.getModifiers() & 
Opcodes.ACC_STATIC) == 0) {
-                                    try {
-                                        theClass.getDeclaredField("this$0");
-                                        outer = getAttribute(receiver, 
"this$0");
-                                    } catch (NoSuchFieldException e) {
-                                    }
-                                }
-                                return omc.getProperty(outerClass, outer, 
getName(), false, false);
-                            } catch (MissingPropertyException suppressed) {
-                                mpe.addSuppressed(suppressed);
-                            } catch (Throwable t) {
-                                t.printStackTrace();
-                            }
-                        }
-                    }
-                    throw mpe;
+                    return getOuterProperty(sender, receiver, getName(), mpe);
                 }
             }
         };
@@ -2835,27 +2830,32 @@ public class MetaClassImpl implements MetaClass, 
MutableMetaClass {
         if (mp != null) {
             throw new ReadOnlyPropertyException(name, theClass);
         }
-        if (!isStatic) {
-            invokeMissingProperty(object, name, newValue, false);
-        } else {
-            try {
+        try {
+            if (!isStatic) {
+                invokeMissingProperty(object, name, newValue, false);
+            } else {
                 invokeStaticMissingProperty(object, name, newValue, false);
-            } catch (MissingPropertyException missing) {
-                if (isGroovyObject()) { // GROOVY-11823, et al.
-                    var outerClass = theClass.getEnclosingClass();
-                    if (outerClass != null && sender.isNestmateOf(outerClass)) 
{
-                        try {
-                            MetaClass omc = registry.getMetaClass(outerClass);
-                            omc.setProperty(sender, outerClass, name, 
newValue, false, false);
-                            return;
-                        } catch (MissingPropertyException mpe) {
-                            missing.addSuppressed(mpe);
-                        }
-                    }
+            }
+        } catch (MissingPropertyException e) {
+            if (!useSuper) setOuterProperty(sender, object, name, newValue, 
e); else throw e; // GROOVY-11823
+        }
+    }
+
+    private void setOuterProperty(Class<?> sender, final Object object, final 
String name, final Object newValue, final MissingPropertyException mpe) {
+        if (sender == null) sender = theClass; // GROOVY-11745
+        if (sender == theClass ? isGroovyObject() : 
GroovyObject.class.isAssignableFrom(sender)) {
+            var outerClass = sender.getEnclosingClass(); // check outer class 
nesting of call site
+            if (outerClass != null && (sender == theClass || 
sender.isAssignableFrom(theClass))) {
+                MetaClass omc = registry.getMetaClass(outerClass);
+                try {
+                    omc.setProperty(outerClass, outerClass, name, newValue, 
false, false);
+                    return;
+                } catch (MissingPropertyException e) {
+                    mpe.addSuppressed(e);
                 }
-                throw missing;
             }
         }
+        throw mpe;
     }
 
     private MetaProperty getMetaProperty(final Class<?> clazz, final String 
name, final boolean useSuper, final boolean useStatic) {
diff --git 
a/src/main/java/org/codehaus/groovy/classgen/EnumCompletionVisitor.java 
b/src/main/java/org/codehaus/groovy/classgen/EnumCompletionVisitor.java
index cd12c3b993..1d0d9653ae 100644
--- a/src/main/java/org/codehaus/groovy/classgen/EnumCompletionVisitor.java
+++ b/src/main/java/org/codehaus/groovy/classgen/EnumCompletionVisitor.java
@@ -23,7 +23,6 @@ import org.codehaus.groovy.ast.ClassHelper;
 import org.codehaus.groovy.ast.ClassNode;
 import org.codehaus.groovy.ast.CodeVisitorSupport;
 import org.codehaus.groovy.ast.ConstructorNode;
-import org.codehaus.groovy.ast.InnerClassNode;
 import org.codehaus.groovy.ast.Parameter;
 import org.codehaus.groovy.ast.expr.ArgumentListExpression;
 import org.codehaus.groovy.ast.expr.CastExpression;
@@ -44,15 +43,7 @@ import java.util.List;
 
 import static java.util.stream.Collectors.toList;
 import static 
org.apache.groovy.ast.tools.ClassNodeUtils.addGeneratedConstructor;
-import static org.codehaus.groovy.ast.ClassHelper.OBJECT_TYPE;
-import static org.codehaus.groovy.ast.ClassHelper.STRING_TYPE;
-import static org.codehaus.groovy.ast.ClassHelper.VOID_TYPE;
-import static org.codehaus.groovy.ast.tools.GeneralUtils.classX;
-import static org.codehaus.groovy.ast.tools.GeneralUtils.param;
-import static org.codehaus.groovy.ast.tools.GeneralUtils.params;
-import static 
org.codehaus.groovy.transform.sc.StaticCompilationVisitor.isStaticallyCompiled;
 import static org.objectweb.asm.Opcodes.ACC_PRIVATE;
-import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
 import static org.objectweb.asm.Opcodes.ACC_SYNTHETIC;
 
 /**
@@ -93,11 +84,6 @@ public class EnumCompletionVisitor extends 
ClassCodeVisitorSupport {
         for (ConstructorNode ctor : nonSyntheticConstructors(enumClass)) {
             transformConstructor(ctor);
         }
-
-        var outerClass = enumClass.getOuterClass(); // GROOVY-7024
-        if (outerClass != null && !isStaticallyCompiled(enumClass)) {
-            addOuterClassDispatch((InnerClassNode) enumClass, outerClass);
-        }
     }
 
     /**
@@ -206,41 +192,4 @@ public class EnumCompletionVisitor extends 
ClassCodeVisitorSupport {
     private static List<ConstructorNode> nonSyntheticConstructors(final 
ClassNode cn) {
         return cn.getDeclaredConstructors().stream().filter(c -> 
!c.isSynthetic()).collect(toList());
     }
-
-    private void addOuterClassDispatch(final InnerClassNode innerClass, final 
ClassNode outerClass) {
-        var visitor = new InnerClassCompletionVisitor(null, sourceUnit);
-
-        visitor.addMissingHandler(
-                innerClass,
-                "methodMissing",
-                ACC_PUBLIC,
-                OBJECT_TYPE,
-                params(param(STRING_TYPE, "name"), param(OBJECT_TYPE, "args")),
-                (methodBody, parameters) -> {
-                    
InnerClassVisitorHelper.setMethodDispatcherCode(methodBody, classX(outerClass), 
parameters);
-                }
-        );
-
-        visitor.addMissingHandler(
-                innerClass,
-                "propertyMissing",
-                ACC_PUBLIC,
-                OBJECT_TYPE,
-                params(param(STRING_TYPE, "name")),
-                (methodBody, parameters) -> {
-                    
InnerClassVisitorHelper.setPropertyGetterDispatcher(methodBody, 
classX(outerClass), parameters);
-                }
-        );
-
-        visitor.addMissingHandler(
-                innerClass,
-                "propertyMissing",
-                ACC_PUBLIC,
-                VOID_TYPE,
-                params(param(STRING_TYPE, "name"), param(OBJECT_TYPE, 
"value")),
-                (methodBody, parameters) -> {
-                    
InnerClassVisitorHelper.setPropertySetterDispatcher(methodBody, 
classX(outerClass), parameters);
-                }
-        );
-    }
 }
diff --git 
a/src/main/java/org/codehaus/groovy/classgen/InnerClassCompletionVisitor.java 
b/src/main/java/org/codehaus/groovy/classgen/InnerClassCompletionVisitor.java
index 3217289209..8706be493b 100644
--- 
a/src/main/java/org/codehaus/groovy/classgen/InnerClassCompletionVisitor.java
+++ 
b/src/main/java/org/codehaus/groovy/classgen/InnerClassCompletionVisitor.java
@@ -120,7 +120,7 @@ public class InnerClassCompletionVisitor extends 
InnerClassVisitorHelper {
 
             boolean innerPojo = hasAnnotation(node, new ClassNode(POJO.class))
                     && hasAnnotation(node, new ClassNode(CompileStatic.class));
-            if (!innerPojo) {
+            if (!innerPojo && !isStatic(innerClass)) {
                 addMopMethods(innerClass);
             }
         }
@@ -307,7 +307,7 @@ public class InnerClassCompletionVisitor extends 
InnerClassVisitorHelper {
         );
     }
 
-    /*   */ void addMissingHandler(final InnerClassNode innerClass, final 
String methodName, final int modifiers,
+    private void addMissingHandler(final InnerClassNode innerClass, final 
String methodName, final int modifiers,
             final ClassNode returnType, final Parameter[] parameters, final 
BiConsumer<BlockStatement, Parameter[]> consumer) {
         MethodNode method = innerClass.getDeclaredMethod(methodName, 
parameters);
         if (method == null) {
diff --git a/src/test/groovy/gls/innerClass/InnerClassTest.groovy 
b/src/test/groovy/gls/innerClass/InnerClassTest.groovy
index a4fdb45a7d..90f7f7a1ae 100644
--- a/src/test/groovy/gls/innerClass/InnerClassTest.groovy
+++ b/src/test/groovy/gls/innerClass/InnerClassTest.groovy
@@ -406,8 +406,10 @@ final class InnerClassTest {
     void testStaticInnerClass2() {
         assertScript '''
             class A {
-                static class B {}
+                static class B {
+                }
             }
+
             assert A.declaredClasses.length == 1
             assert A.declaredClasses[0] == A.B
         '''
@@ -419,11 +421,12 @@ final class InnerClassTest {
             class A {
                 static class B {
                     String p
+                    String getQ() { WHY }
                 }
                 B m() {
                     return [p:'x'] // calls 
ScriptBytecodeAdapter.castToType([p:'x'], A$B.class)
                 }
-                static final String q = 'y'
+                private static final String WHY = 'y'
             }
 
             o = new A().m()
@@ -936,6 +939,22 @@ final class InnerClassTest {
         '''
     }
 
+    @NotYetImplemented @Test
+    void testUsageOfOuterField14() {
+        assertScript '''
+            class Outer {
+                interface Inner {
+                    default i() {
+                        'i' + o
+                    }
+                }
+                private static o = 'o'
+            }
+
+            assert (new Outer.Inner() {}).i() == 'io'
+        '''
+    }
+
     @Test
     void testUsageOfOuterSuperField() {
         assertScript '''
@@ -1085,6 +1104,7 @@ final class InnerClassTest {
                     runner.run()
                 }
             }
+
             def foo = new Foo()
             assert foo.foo() == 1
         '''
@@ -1106,6 +1126,7 @@ final class InnerClassTest {
                     runner.run()
                 }
             }
+
             def foo = new Foo()
             assert foo.foo() == 1
         '''
@@ -1126,6 +1147,7 @@ final class InnerClassTest {
                     runner.run()
                 }
             }
+
             def foo = new Foo()
             assert foo.foo() == 1
         '''
@@ -1147,6 +1169,7 @@ final class InnerClassTest {
                     runner.run()
                 }
             }
+
             def foo = new Foo()
             assert foo.foo() == 1
         '''
@@ -1297,6 +1320,22 @@ final class InnerClassTest {
         '''
     }
 
+    @NotYetImplemented @Test
+    void testUsageOfOuterMethod10() {
+        assertScript '''
+            class Outer {
+                interface Inner {
+                    default i() {
+                        'i' + o()
+                    }
+                }
+                private static o() { 'o' }
+            }
+
+            assert (new Outer.Inner() {}).i() == 'io'
+        '''
+    }
+
     @Test
     void testUsageOfOuterMethodOverridden() {
         assertScript '''
@@ -2184,6 +2223,7 @@ final class InnerClassTest {
                     inner.inner()
                 }
             }
+
             assert new Outer().test() == 1
         '''
     }
@@ -2205,17 +2245,18 @@ final class InnerClassTest {
                     }
                 }
             }
+
             new Outer().obj.toString()
         '''
     }
 
     // GROOVY-8274
     @Test
-    void testMissingMethodHandling() {
+    void testMethodMissing1() {
         assertScript '''
             class Outer {
                 class Inner {
-                    def methodMissing(String name, args) {
+                    def methodMissing(String name, Object args) {
                         return name
                     }
                 }
@@ -2234,6 +2275,68 @@ final class InnerClassTest {
         '''
     }
 
+    @Test
+    void testMethodMissing2() {
+        assertScript '''
+            class Outer {
+                class Inner {
+                    def methodMissing(String name, Object args) {
+                        return 42
+                    }
+                    def propertyMissing(String name) {
+                        return 42
+                    }
+                }
+            }
+
+            def i = new Outer.Inner(new Outer())
+            assert i.foo()  == 42
+            assert i.foobar == 42
+        '''
+    }
+
+    @Test
+    void testMethodMissing3() {
+        assertScript '''
+            class Outer {
+                static class Inner {
+                    def methodMissing(String name, Object args) {
+                        return 42
+                    }
+                    def propertyMissing(String name) {
+                        return 42
+                    }
+                }
+            }
+
+            def i = new Outer.Inner()
+            assert i.foo()  == 42
+            assert i.foobar == 42
+        '''
+    }
+
+    @Test
+    void testMethodMissing4() {
+        assertScript '''
+            class Outer {
+                static class Inner {
+                    def methodMissing(String name, Object args) {
+                        return 42
+                    }
+                    def propertyMissing(String name) {
+                        return 42
+                    }
+                }
+                static class Other extends Inner {
+                }
+            }
+
+            def o = new Outer.Other()
+            assert o.foo()  == 42
+            assert o.foobar == 42
+        '''
+    }
+
     // GROOVY-6831
     @Test
     void testNestedPropertyHandling() {
@@ -2295,6 +2398,7 @@ final class InnerClassTest {
         def err = shouldFail """
             class Upper {
                 $returnType propertyMissing(String name, Object value) {
+                    throw new MissingPropertyException(name, getClass())
                 }
             }
             class Outer {
@@ -2306,6 +2410,41 @@ final class InnerClassTest {
         assert err =~ /No such property: missing for class: Outer.Inner/
     }
 
+    // GROOVY-9618
+    @Test
+    void testNestedPropertyHandling5() {
+        assertScript '''
+            class Super {
+                public static X = 1
+                static getX() { 2 }
+            }
+            class Outer extends Super {
+                static class Inner {
+                    def m() { X }
+                }
+            }
+
+            assert new Outer.Inner().m() == 2
+        '''
+
+        def err = shouldFail '''
+            class Outer {
+                public static X = 1
+                static getX() { 2 }
+                static class Inner {
+                }
+            }
+            class Other extends Outer.Inner {
+                def m() {
+                    X // can't read super outer this way
+                }
+            }
+
+            new Other().m()
+        '''
+        assert err =~ /MissingPropertyException: No such property: X for 
class: Other/
+    }
+
     // GROOVY-7312
     @Test
     void testInnerClassOfInterfaceIsStatic() {
diff --git a/src/test/groovy/groovy/ClosureTest.groovy 
b/src/test/groovy/groovy/ClosureTest.groovy
index 829645151d..7797016645 100644
--- a/src/test/groovy/groovy/ClosureTest.groovy
+++ b/src/test/groovy/groovy/ClosureTest.groovy
@@ -18,8 +18,9 @@
  */
 package groovy
 
-import org.codehaus.groovy.control.MultipleCompilationErrorsException
-import org.junit.Test
+import org.junit.jupiter.api.Test
+import org.junit.jupiter.params.ParameterizedTest
+import org.junit.jupiter.params.provider.ValueSource
 
 import static groovy.test.GroovyAssert.assertScript
 import static groovy.test.GroovyAssert.shouldFail
@@ -484,72 +485,6 @@ final class ClosureTest {
         '''
     }
 
-    @Test
-    void testStaticInnerClassOwnerWithPropertyMissingImplementation() {
-        def err = shouldFail MultipleCompilationErrorsException, '''
-            class ClosureTestA {
-                static class ClosureTestB {
-                    def propertyMissing(String myName, Object myValue) {
-                        return myValue
-                    }
-
-                    def propertyMissing(String myName) {
-                        return 42
-                    }
-
-                    def methodMissing(String myName, Object myArgs) {
-                        return 42
-                    }
-                }
-            }
-        '''
-
-        assert err.message.contains('"methodMissing" implementations are not 
supported on static inner classes as a synthetic version of "methodMissing" is 
added during compilation for the purpose of outer class delegation.')
-        assert err.message.contains('"propertyMissing" implementations are not 
supported on static inner classes as a synthetic version of "propertyMissing" 
is added during compilation for the purpose of outer class delegation.')
-    }
-
-    @Test
-    void testInnerClassOwnerWithPropertyMissingImplementation() {
-        assertScript '''
-            class ClosureTestA {
-                class ClosureTestB {
-                    def propertyMissing(String myName, Object myValue) {
-                        return myValue
-                    }
-
-                    def propertyMissing(String myName) {
-                        return 42
-                    }
-
-                    def methodMissing(String myName, Object myArgs) {
-                        return 42
-                    }
-                }
-            }
-
-            def a = new ClosureTestA()
-            def b = new ClosureTestA.ClosureTestB(a)
-        '''
-    }
-
-    @Test
-    void testStaticInnerClassHierarchyWithMethodMissing() {
-        def err = shouldFail MultipleCompilationErrorsException, '''
-            class ClosureTestA {
-                static class ClosureTestB {
-                    def methodMissing(String myName, Object myArgs) {
-                        return 42
-                    }
-                }
-
-                static class ClosureTestB1 extends ClosureTestB {
-                }
-            }
-        '''
-
-        assert err.message.contains('"methodMissing" implementations are not 
supported on static inner classes as a synthetic version of "methodMissing" is 
added during compilation for the purpose of outer class delegation.')
-    }
-
     // GROOVY-10943
     @Test
     void testClosureUnderscorePlaceholder() {
@@ -564,150 +499,148 @@ final class ClosureTest {
     }
 
     // GROOVY-2433, GROOVY-3073, GROOVY-9987, GROOVY-11128
-    @Test
-    void testClosureAccessToEnclosingClassPrivateMethod() {
-        for (who in ['this.', 'owner.', 'thisObject.', '']) {
-            assertScript """
-                class C {
-                    def getIds() {
-                        populateIds()
-                    }
-                    def populateIds = { ->
-                        ${who}sort([ 1, 5, 3, 4, 2 ])
-                    }
-                    private sort(list) {
-                        list.sort{ one, two -> one <=> two }
-                    }
+    @ParameterizedTest
+    @ValueSource(strings=['this.', 'owner.', 'thisObject.', ''])
+    void testClosureAccessToEnclosingClassPrivateMethod(String who) {
+        assertScript """
+            class C {
+                def getIds() {
+                    populateIds()
                 }
+                def populateIds = { ->
+                    ${who}sort([ 1, 5, 3, 4, 2 ])
+                }
+                private sort(list) {
+                    list.sort{ one, two -> one <=> two }
+                }
+            }
 
-                class D extends C {
-                    void test() {
-                        assert ids == [1,2,3,4,5]
-                    }
+            class D extends C {
+                void test() {
+                    assert ids == [1,2,3,4,5]
                 }
+            }
 
-                new D().test()
-            """
+            new D().test()
+        """
 
-            assertScript """
-                class C {
-                    protected String protectedMethod() {
-                        def closure = { ->
-                            ${who}privateMethod()
-                        }
-                        closure()
-                    }
-                    private String privateMethod() {
-                        'hello world'
+        assertScript """
+            class C {
+                protected String protectedMethod() {
+                    def closure = { ->
+                        ${who}privateMethod()
                     }
+                    closure()
+                }
+                private String privateMethod() {
+                    'hello world'
                 }
+            }
 
-                class D extends C {
-                    void test() {
-                        def result = protectedMethod()
-                        assert result == 'hello world'
-                    }
+            class D extends C {
+                void test() {
+                    def result = protectedMethod()
+                    assert result == 'hello world'
                 }
+            }
 
-                new D().test()
-            """
+            new D().test()
+        """
 
-            assertScript """
-                class C {
-                    def publicMethod() {
-                        [1].each {
-                            ${who}privateStaticMethod()
-                        }
-                    }
-                    private static privateStaticMethod() {
-                        'hello world'
+        assertScript """
+            class C {
+                def publicMethod() {
+                    [1].each {
+                        ${who}privateStaticMethod()
                     }
                 }
+                private static privateStaticMethod() {
+                    'hello world'
+                }
+            }
 
-                class D extends C {
-                    void test() {
-                        publicMethod()
-                    }
+            class D extends C {
+                void test() {
+                    publicMethod()
                 }
+            }
 
-                new D().test()
-            """
-        }
+            new D().test()
+        """
     }
 
     // GROOVY-3142, GROOVY-5438, GROOVY-6335, GROOVY-11128
-    @Test
-    void testClosureAccessToEnclosingClassPrivateField() {
-        for (who in ['this.@', 'this.', 'owner.', 'thisObject.', '']) {
-            assertScript """
-                class C {
-                    String data
-                    C(arg) {
-                        arg.each() { ${who}data = it } // MissingFieldException
-                    }
+    @ParameterizedTest
+    @ValueSource(strings=['this.@', 'this.', 'owner.', 'thisObject.', ''])
+    void testClosureAccessToEnclosingClassPrivateField(String who) {
+        assertScript """
+            class C {
+                String data
+                C(arg) {
+                    arg.each() { ${who}data = it } // MissingFieldException
                 }
+            }
 
-                class D extends C {
-                    D(arg) {
-                        super(arg)
-                    }
+            class D extends C {
+                D(arg) {
+                    super(arg)
                 }
+            }
 
-                new D(["test"])
-            """
+            new D(["test"])
+        """
 
-            assertScript """
-                class C {
-                    private String data
-                    C(arg) {
-                        arg.each() { ${who}data = it } // 
ReadOnlyPropertyException
-                    }
-                    String getData() { this.@data }
-                    private void setData(String value) { this.@data = value }
+        assertScript """
+            class C {
+                private String data
+                C(arg) {
+                    arg.each() { ${who}data = it } // ReadOnlyPropertyException
                 }
+                String getData() { this.@data }
+                private void setData(String value) { this.@data = value }
+            }
 
-                class D extends C {
-                    D(arg) {
-                        super(arg)
-                    }
+            class D extends C {
+                D(arg) {
+                    super(arg)
                 }
+            }
 
-                new D(["test"])
-            """
+            new D(["test"])
+        """
 
-            assertScript """
-                class C {
-                    private String string = 'foo'
-                    def test(List<String> strings) {
-                        strings.collect { ${who}string + it }
-                    }
+        assertScript """
+            class C {
+                private String string = 'foo'
+                def test(List<String> strings) {
+                    strings.collect { ${who}string + it }
                 }
+            }
 
-                def result = new C().test(['bar','baz'])
-                assert result == ['foobar','foobaz']
+            def result = new C().test(['bar','baz'])
+            assert result == ['foobar','foobaz']
 
-                class D extends C {
-                }
+            class D extends C {
+            }
+
+            result = new D().test(['bar','baz'])
+            assert result == ['foobar','foobaz']
+        """
 
-                result = new D().test(['bar','baz'])
-                assert result == ['foobar','foobaz']
-            """
-
-            assertScript """
-                @groovy.util.logging.Log
-                class C {
-                    void test() {
-                        1.times {
-                            ${who}log.info('sth')
-                        }
+        assertScript """
+            @groovy.util.logging.Log
+            class C {
+                void test() {
+                    1.times {
+                        ${who}log.info('sth')
                     }
                 }
+            }
 
-                class D extends C {
-                }
+            class D extends C {
+            }
 
-                new D().test()
-            """
-        }
+            new D().test()
+        """
     }
 }
diff --git a/src/test/groovy/groovy/PropertyTest.groovy 
b/src/test/groovy/groovy/PropertyTest.groovy
index 761fcde041..2b2547912e 100644
--- a/src/test/groovy/groovy/PropertyTest.groovy
+++ b/src/test/groovy/groovy/PropertyTest.groovy
@@ -831,24 +831,6 @@ final class PropertyTest {
         '''
     }
 
-    // GROOVY-9618
-    @Test
-    void testPropertyAndStaticUppercaseFieldPriority() {
-        assertScript '''
-            class A {
-                public static X = 1
-                static getX() { 2 }
-                static class B { }
-            }
-            class C extends A.B {
-                def test() {
-                    X
-                }
-            }
-            assert new C().test() == 2
-        '''
-    }
-
     
//--------------------------------------------------------------------------
 
     static class Base {
diff --git 
a/src/test/groovy/org/codehaus/groovy/transform/packageScope/PackageScopeTransformTest.groovy
 
b/src/test/groovy/org/codehaus/groovy/transform/packageScope/PackageScopeTransformTest.groovy
index 12f3a5e6e6..ee3ccaa267 100644
--- 
a/src/test/groovy/org/codehaus/groovy/transform/packageScope/PackageScopeTransformTest.groovy
+++ 
b/src/test/groovy/org/codehaus/groovy/transform/packageScope/PackageScopeTransformTest.groovy
@@ -191,7 +191,7 @@ final class PackageScopeTransformTest {
             import groovy.transform.PackageScope
 
             @CompileStatic
-            class Test {
+            class Outer {
                 @PackageScope static final String S = 'S'
                 protected static final String T = 'T'
                 private static final String U = 'U'
@@ -202,7 +202,7 @@ final class PackageScopeTransformTest {
                 }
             }
 
-            assert new Test.Inner().method() == 'STU'
+            assert new Outer.Inner().method() == 'STU'
         '''
     }
 }


Reply via email to