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 2020/12/07 22:10:03 UTC

[jira] [Closed] (GROOVY-9814) Method reference doesn't accept subtypes of argument

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

Paul King closed GROOVY-9814.
-----------------------------

> Method reference doesn't accept subtypes of argument
> ----------------------------------------------------
>
>                 Key: GROOVY-9814
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9814
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 3.0.6
>            Reporter: Christopher Smith
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 3.0.7, 4.0.0-alpha-2
>
>         Attachments: Groovy9814.groovy
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> When using a method reference such as {{HasId::getId}}, the compiler implements the request by generating a {{MethodClosure}}. However, the closure accepts only the exact type of the reference, not subtypes. All compile-time checks pass, but the closure throws {{MissingMethodException}} at runtime with the message
> {code}
> No signature of method: org.codehaus.groovy.runtime.MethodClosure.getId() is applicable for argument types: (com.example.ClassWithId)
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)