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

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

commit 2f0a6feb8ecee496f47a010d1832d5b0421a4a5f
Author: Eric Milles <[email protected]>
AuthorDate: Fri May 23 19:41:44 2025 -0500

    GROOVY-11676: object expression type in `MethodClosure` error message
---
 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 445c018675..d2c6905148 100644
--- a/src/main/java/groovy/lang/MetaClassImpl.java
+++ b/src/main/java/groovy/lang/MetaClassImpl.java
@@ -1062,7 +1062,13 @@ public class MetaClassImpl implements MetaClass, 
MutableMetaClass {
                     } catch (MissingMethodException ignore) {}
                 }
 
-                return invokeMissingMethod(closure, method, arguments);
+                try {
+                    return invokeMissingMethod(closure, 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 471df3ac35..1fe74659df 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: m for class: C is applicable 
for argument types: \(\) values: \[\]/
 
-        shouldFail MissingMethodException, base + '''
+        /**/err = shouldFail MissingMethodException, base + '''
             closure("")
         '''
+        assert err =~ /No signature of method: m for class: C is applicable 
for argument types: \(String\) values: \[\]/
     }
 
     @Test

Reply via email to