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

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


The following commit(s) were added to refs/heads/GROOVY_4_0_X by this push:
     new ef31977413 GROOVY-11676: object expression type in `MethodClosure` 
error message
ef31977413 is described below

commit ef31977413c00b1cdb78e3e7b7af77e07dbd4482
Author: Eric Milles <[email protected]>
AuthorDate: Sun Jun 1 14:23:31 2025 -0500

    GROOVY-11676: object expression type in `MethodClosure` error message
    
    4_0_X backport
---
 src/main/java/groovy/lang/MetaClassImpl.java  | 8 +++++++-
 src/test/groovy/bugs/MethodClosureTest.groovy | 8 +++++---
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/main/java/groovy/lang/MetaClassImpl.java 
b/src/main/java/groovy/lang/MetaClassImpl.java
index 7e5889ea67..0116db72e5 100644
--- a/src/main/java/groovy/lang/MetaClassImpl.java
+++ b/src/main/java/groovy/lang/MetaClassImpl.java
@@ -1061,7 +1061,13 @@ public class MetaClassImpl implements MetaClass, 
MutableMetaClass {
                     } catch (MissingMethodException ignore) {}
                 }
 
-                return invokeMissingMethod(object, method, arguments);
+                try {
+                    return invokeMissingMethod(object, method, arguments);
+                } catch (MissingMethodException mme) { // GROOVY-11676: owner 
class
+                    mme = new MissingMethodException(method, ownerClass, 
arguments);
+                    mme.addSuppressed(e);
+                    throw mme;
+                }
             }
         }
     }
diff --git a/src/test/groovy/bugs/MethodClosureTest.groovy 
b/src/test/groovy/bugs/MethodClosureTest.groovy
index a61ed18f41..3a840d6ee1 100644
--- a/src/test/groovy/bugs/MethodClosureTest.groovy
+++ b/src/test/groovy/bugs/MethodClosureTest.groovy
@@ -81,7 +81,7 @@ final class MethodClosureTest {
         '''
     }
 
-    // GROOVY-9140
+    // GROOVY-9140, GROOVY-11676
     @Test
     void testMethodClosureWithoutThis() {
         String base = '''
@@ -96,13 +96,15 @@ final class MethodClosureTest {
             assert result == 11
         '''
 
-        shouldFail MissingMethodException, base + '''
+        def err = shouldFail MissingMethodException, base + '''
             closure()
         '''
+        assert err =~ /No signature of method: C.m\(\) is applicable for 
argument types: \(\) values: \[\]/
 
-        shouldFail MissingMethodException, base + '''
+        /**/err = shouldFail MissingMethodException, base + '''
             closure("")
         '''
+        assert err =~ /No signature of method: C.m\(\) is applicable for 
argument types: \(String\) values: \[\]/
     }
 
     @Test

Reply via email to