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

paulk 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 2a7d1e9b5a minor refactor: remove deprecated method usage
2a7d1e9b5a is described below

commit 2a7d1e9b5a6bc86392dd37d050130ce0929b6eff
Author: Paul King <[email protected]>
AuthorDate: Sun Mar 29 12:30:49 2026 +1000

    minor refactor: remove deprecated method usage
---
 .../groovy/runtime/metaclass/ClosureMetaClass.java |  2 --
 .../gls/invocation/MethodSelectionTest.groovy      | 27 ++++++++++++++++++++++
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git 
a/src/main/java/org/codehaus/groovy/runtime/metaclass/ClosureMetaClass.java 
b/src/main/java/org/codehaus/groovy/runtime/metaclass/ClosureMetaClass.java
index ca7d105187..5919ca071b 100644
--- a/src/main/java/org/codehaus/groovy/runtime/metaclass/ClosureMetaClass.java
+++ b/src/main/java/org/codehaus/groovy/runtime/metaclass/ClosureMetaClass.java
@@ -145,8 +145,6 @@ public final class ClosureMetaClass extends MetaClassImpl {
         public Object chooseMethod(final Class<?>[] arguments, final boolean 
coerce) {
             if (arguments.length == 0) {
                 return MetaClassHelper.chooseEmptyMethodParams(methods);
-            } else if (arguments.length == 1 && arguments[0] == null) {
-                return 
MetaClassHelper.chooseMostGeneralMethodWith1NullParam(methods);
             } else {
                 int methodCount = methods.size();
                 List<Object> matchingMethods = new ArrayList<>(methodCount);
diff --git a/src/test/groovy/gls/invocation/MethodSelectionTest.groovy 
b/src/test/groovy/gls/invocation/MethodSelectionTest.groovy
index eea754d848..44e0a01690 100644
--- a/src/test/groovy/gls/invocation/MethodSelectionTest.groovy
+++ b/src/test/groovy/gls/invocation/MethodSelectionTest.groovy
@@ -102,6 +102,33 @@ final class MethodSelectionTest extends 
CompilableTestSupport {
         '''
     }
 
+    @Test // GROOVY-6289: closure doCall with null selects most specific 
applicable method
+    void testClosureCallWithNullSelectsMethod() {
+        assertScript '''
+            class MyClosure extends Closure {
+                MyClosure(owner) { super(owner) }
+                def doCall(String s) { 'string' }
+                def doCall(Integer i) { 'integer' }
+            }
+            // String is more specific than Integer for null (both reference 
types)
+            assert new MyClosure(this)(null) == 'string'
+        '''
+    }
+
+    @Test // GROOVY-6289: closure doCall with null and unrelated types should 
be ambiguous
+    void testClosureCallWithNullAmbiguous() {
+        shouldFail '''
+            class A {}
+            class B {}
+            class MyClosure extends Closure {
+                MyClosure(owner) { super(owner) }
+                def doCall(A a) { 'a' }
+                def doCall(B b) { 'b' }
+            }
+            new MyClosure(this)(null)
+        '''
+    }
+
     @Test
     void testMethodSelectionException() {
         assertScript '''

Reply via email to