Paul King created GROOVY-9140:
---------------------------------

             Summary: Class.&instanceMethod with incorrect first param
                 Key: GROOVY-9140
                 URL: https://issues.apache.org/jira/browse/GROOVY-9140
             Project: Groovy
          Issue Type: Dependency upgrade
    Affects Versions: 3.0.0-beta-1
            Reporter: Paul King


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.:
{code}
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?]
{code}




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to