You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2019/07/22 04:22:02 UTC

[jira] [Closed] (GROOVY-9140) Class.&instanceMethod with incorrect first param

     [ https://issues.apache.org/jira/browse/GROOVY-9140?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul King closed GROOVY-9140.
-----------------------------

> Class.&instanceMethod with incorrect first param
> ------------------------------------------------
>
>                 Key: GROOVY-9140
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9140
>             Project: Groovy
>          Issue Type: Improvement
>    Affects Versions: 3.0.0-beta-1
>            Reporter: Paul King
>            Assignee: Paul King
>            Priority: Major
>             Fix For: 3.0.0-beta-2
>
>
> 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.14#76016)