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

Paul King closed GROOVY-11467.
------------------------------

> Failed to find method when using method reference on a class field
> ------------------------------------------------------------------
>
>                 Key: GROOVY-11467
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11467
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>            Reporter: Thodoris Sotiropoulos
>            Assignee: Eric Milles
>            Priority: Minor
>             Fix For: 3.0.23, 4.0.23, 5.0.0-alpha-10
>
>
> I have the following program
> {code:java}
> import java.util.function.Supplier
> interface A {
>   Double m()
> }
> interface B extends A {
> }
> class C implements B {
>   Integer m() { 42 }
> }
> @groovy.transform.CompileStatic
> class Test {
>   B f = new C()
>   public void test() {
>     Supplier<Integer> s = f::m
>     assert s.get() == 42
>   }
> }
> {code}
> h3. Actual behavior
> The code is rejected with
> {code:java}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> test.groovy: 17: Failed to find method 'm()' for the type: B @ line 17, 
> column 26.
>        Supplier<Double> x = f::m;
>                             ^1 error
>  {code}
> h3. Expected behavior
> The code should have been compiled successfully.
>  
> h3. Notes
> There are two requirements for this bug:
> # The type of the receiver should be an interface (e.g., B) that extends the 
> interface where the method is defined.
> # The receiver should be a field.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to