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

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


The following commit(s) were added to refs/heads/master by this push:
     new 86cf6f1dbd GROOVY-7685: Object category method and closure method call
86cf6f1dbd is described below

commit 86cf6f1dbd9d0cdf0c73c8903f3830b2e3188b30
Author: Eric Milles <[email protected]>
AuthorDate: Sat Mar 14 13:58:37 2026 -0500

    GROOVY-7685: Object category method and closure method call
---
 src/main/java/groovy/lang/MetaClassImpl.java |  3 ++-
 src/test/groovy/groovy/CategoryTest.groovy   | 26 ++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/src/main/java/groovy/lang/MetaClassImpl.java 
b/src/main/java/groovy/lang/MetaClassImpl.java
index a2f026ba31..bdd771341b 100644
--- a/src/main/java/groovy/lang/MetaClassImpl.java
+++ b/src/main/java/groovy/lang/MetaClassImpl.java
@@ -710,7 +710,8 @@ public class MetaClassImpl implements MetaClass, 
MutableMetaClass {
                 }
                 for (CategoryMethod cm : methods) {
                     Class<?> cmdc = cm.getDeclaringClass().getTheClass();
-                    if (cmdc.isAssignableFrom(theClass)) // GROOVY-11813: not 
sender
+                    if (cmdc == Object.class ? !isGroovyFunctor() // 
GROOVY-7685
+                                             : 
cmdc.isAssignableFrom(theClass)) // GROOVY-11813
                         filterMatchingMethodForCategory(array, cm);
                 }
                 answer = array;
diff --git a/src/test/groovy/groovy/CategoryTest.groovy 
b/src/test/groovy/groovy/CategoryTest.groovy
index 848410404e..0aaebba147 100644
--- a/src/test/groovy/groovy/CategoryTest.groovy
+++ b/src/test/groovy/groovy/CategoryTest.groovy
@@ -432,6 +432,32 @@ final class CategoryTest {
         '''
     }
 
+    // GROOVY-7685
+    @Test
+    void testCategoryMethodAndClosureResolveStrategy() {
+        assertScript '''
+            class C {
+                static m(self) {
+                    'Category'
+                }
+            }
+            class D {
+                def m() {
+                    'Delegate'
+                }
+            }
+
+            use(C) {
+                def x = { ->
+                    assert m() == 'Delegate'
+                }
+                x.resolveStrategy = Closure.DELEGATE_ONLY
+                x.delegate = new D()
+                x.call()
+            }
+        '''
+    }
+
     // GROOVY-11813
     @Test
     void testCategoryOperatorMethodAndCustomMetaClass() {

Reply via email to