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 2026/01/24 17:25:37 UTC

(groovy) branch GROOVY-4737 created (now 5329496eb0)

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

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


      at 5329496eb0 4737, 4862, 5875, 6580, 6581

This branch includes the following new commits:

     new 5329496eb0 4737, 4862, 5875, 6580, 6581

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: 4737, 4862, 5875, 6580, 6581

Posted by em...@apache.org.
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 5329496eb0478002fa98e136d2e430cabc9e68a6
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Sat Jan 24 11:08:04 2026 -0600

    4737, 4862, 5875, 6580, 6581
---
 src/main/java/groovy/lang/MetaClassImpl.java       | 70 +++++++++++++++++++++-
 .../classgen/InnerClassCompletionVisitor.java      | 10 ----
 2 files changed, 67 insertions(+), 13 deletions(-)

diff --git a/src/main/java/groovy/lang/MetaClassImpl.java b/src/main/java/groovy/lang/MetaClassImpl.java
index 94c972b72e..dde3805275 100644
--- a/src/main/java/groovy/lang/MetaClassImpl.java
+++ b/src/main/java/groovy/lang/MetaClassImpl.java
@@ -1899,16 +1899,55 @@ public class MetaClassImpl implements MetaClass, MutableMetaClass {
         //----------------------------------------------------------------------
         // missing property protocol
         //----------------------------------------------------------------------
-        return invokeMissingProperty(object, name, null, true);
+        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;
+        }
     }
 
     private Object getClassProperty(final Class<?> sender, final Class<?> receiver, final String name) throws MissingPropertyException {
         try {
             MetaClass cmc = registry.getMetaClass(Class.class);
             return cmc.getProperty(Class.class, receiver, name, false, false);
-        } catch (MissingPropertyException ignore) {
+        } catch (MissingPropertyException ignored) {
+        }
+
+        try {
             // try $static_propertyMissing / throw MissingPropertyException
             return invokeStaticMissingProperty(receiver, name, null, true);
+        } catch (MissingPropertyException missing) {
+            Class<?> outerClass = theClass.getEnclosingClass();
+            if (outerClass != null && sender.isNestmateOf(outerClass)) {
+                try {
+                    MetaClass omc = registry.getMetaClass(outerClass);
+                    return omc.getProperty(sender, outerClass, name, false, false);
+                } catch (MissingPropertyException mpe) {
+                    missing.addSuppressed(mpe);
+                }
+            }
+            throw missing;
         }
     }
 
@@ -2037,7 +2076,32 @@ public class MetaClassImpl implements MetaClass, MutableMetaClass {
         return new ReadOnlyMetaProperty(name) {
             @Override
             public Object getProperty(final Object receiver) {
-                return invokeMissingProperty(receiver, getName(), null, true);
+                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, name, false, false);
+                            } catch (MissingPropertyException suppressed) {
+                                mpe.addSuppressed(suppressed);
+                            } catch (Throwable t) {
+                                t.printStackTrace();
+                            }
+                        }
+                    }
+                    throw mpe;
+                }
             }
         };
     }
diff --git a/src/main/java/org/codehaus/groovy/classgen/InnerClassCompletionVisitor.java b/src/main/java/org/codehaus/groovy/classgen/InnerClassCompletionVisitor.java
index fb70379836..76eac4653e 100644
--- a/src/main/java/org/codehaus/groovy/classgen/InnerClassCompletionVisitor.java
+++ b/src/main/java/org/codehaus/groovy/classgen/InnerClassCompletionVisitor.java
@@ -325,16 +325,6 @@ public class InnerClassCompletionVisitor extends InnerClassVisitorHelper {
                     }
                 }
         );
-
-        addMissingHandler(node,
-                "$static_propertyMissing",
-                ACC_PUBLIC | ACC_STATIC,
-                OBJECT_TYPE,
-                params(param(STRING_TYPE, "name")),
-                (methodBody, parameters) -> {
-                    setPropertyGetterDispatcher(methodBody, classX(outerClass), parameters);
-                }
-        );
     }
 
     /*   */ void addMissingHandler(final InnerClassNode innerClass, final String methodName, final int modifiers,