Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.0.0-beta-1
-
None
-
None
Description
In Groovy 3 we extended the method pointer to also work for a Class receiver and instance method. When used in this way, the method closure produced accepts an additional initial argument being the instance receiver. This works when supplied with a correct argument but gives an IllegalArgumentException instead of MissingMethodException when an illegal argument is supplied. E.g.:
class Y { def m() {1} } ref = Y.&m assert ref(new Y()) == 1 assert ref() == 1 // => java.lang.IllegalArgumentException: object is not an instance of declaring class [Should just be missing method exception?] assert ref(1) == 1 // => java.lang.IllegalArgumentException: object is not an instance of declaring class [Should just be missing method exception?]