Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
-
None
-
None
Description
the following script fails
def mymethod(Map kwargs=[:], arg1, arg2, Object[] args) { println "arg1: $arg1, arg2: $arg2, args: $args, kwargs: $kwargs" } mymethod('hello', 'world') mymethod('hello', 'world', 'from', 'list') mymethod('hello', 'world', 'from', 'list', from: 'kwargs') mymethod('hello', 'world', from: 'kwargs')
the reason is that the optional map will cause the generation of two methods mymethod and each of these has a vargs argument. Groovy then somehow deselects both of them instead of choosing the most specific method. Code as this might be rarely used, but it should work