Hi there,
isn't this a bug in the method dispatcher? (Works precisely same way with
explicit .plus(...)) I would assume "null: null" to be printed out by the last
command:
===
2016 ocs /tmp> <q.groovy
class Foo {
static main(args) {
ExpandoMetaClass.enableGlobally()
Integer.metaClass.plus<<{ Thread foo -> 'thread' } // just to make sure
adding methods works OK
Integer.metaClass.plus<<{ org.codehaus.groovy.runtime.NullObject foo ->
'null' } // does not here, tho
println "thread: ${7+Thread.currentThread()}"
println "null: ${7+null}"
}
}
2017 ocs /tmp> /usr/local/groovy-4.0.5/bin/groovy q
thread: thread
Caught: groovy.lang.GroovyRuntimeException: Ambiguous method overloading for
method java.lang.Integer#plus.
Cannot resolve which method to invoke for [null] due to overlapping prototypes
between:
[class java.lang.Character]
[class java.lang.String]
[class java.lang.Number]
[class java.lang.Thread]
...
===
Thanks,
OC