
|
If you were logged in you would be able to see more operations.
|
|
|
Running this in the groovyConsole:
void custom(Class cls, Map args) {
println cls.name + " " + args
}
custom(Integer.class, foo:"Bar!")
Gives me this:
groovy.lang.MissingMethodException: No signature of method: Script3.custom() is applicable for argument types: (java.util.LinkedHashMap, java.lang.Class) values: {[foo:Bar!], class java.lang.Integer}
at Script3.run(Script3:5)
I expect the explosion, but it looks like the types of my arguments are getting swapped around before it explodes. In fact, if I swap the order of the arguments around at the call site –
void custom2(Map args, Class cls) {
println cls.name + " " + args
}
}
custom2(Integer.class, foo:"Bar!")
That passes w/o a hitch.
I'm not even sure where to start looking to try to fix this, so I don't have a patch to submit. Sorry!
|
|
Description
|
Running this in the groovyConsole:
void custom(Class cls, Map args) {
println cls.name + " " + args
}
custom(Integer.class, foo:"Bar!")
Gives me this:
groovy.lang.MissingMethodException: No signature of method: Script3.custom() is applicable for argument types: (java.util.LinkedHashMap, java.lang.Class) values: {[foo:Bar!], class java.lang.Integer}
at Script3.run(Script3:5)
I expect the explosion, but it looks like the types of my arguments are getting swapped around before it explodes. In fact, if I swap the order of the arguments around at the call site –
void custom2(Map args, Class cls) {
println cls.name + " " + args
}
}
custom2(Integer.class, foo:"Bar!")
That passes w/o a hitch.
I'm not even sure where to start looking to try to fix this, so I don't have a patch to submit. Sorry! |
Show » |
Sort Order:
|
this is not a bug, because we specified a certain order for arguments: First the map, then normal arguments, then varargs. This gives the signature:
def foo(Map m, p1,p2, ..., pn, Object[] q)if you do a method call
def foo(Map m, x,y,Object[] z)def foo(x,Map m) {1} def foo(Map m,x) {2} assert foo(a:1,2) == 2 assert foo(2,a:1) == 2 assert foo([a:1],2) == 2 assert foo(2,[a:1]) == 1