null-specific argument type?

"[email protected]" <[email protected]> Thu, 30 Jan 2025 22:48:42 +0100
Newsgroups gmane.comp.lang.groovy.user
Message-ID <[email protected]>
Hi there,

is there a way to write a method with argument which would match null specifically when called? This does not work:

===
1022 ocs /tmp> <q.groovy 
class Test {
  def foo(Collection foo) {}
  def foo(Map foo) {}
  def foo(org.codehaus.groovy.runtime.NullObject foo) {}
}
new Test().foo(null)
1023 ocs /tmp> /usr/local/groovy-4.0.25/bin/groovy q 
Caught: groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method Test#foo.
Cannot resolve which method to invoke for [null] due to overlapping prototypes between:
	[interface java.util.Collection]
	[interface java.util.Map]
===

Thanks!
OC