Thodoris Sotiropoulos created GROOVY-11467:
----------------------------------------------

             Summary: 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


I have the following program
{code:java}
import java.util.function.Supplier;
interface A {
  Double m();
}
interface B extends A {}
class C implements B {
  public Double m() { return null; }
}
class Test {
  B f = new C();
  public void test() {
    Supplier<Double> x = f::m;
  }
} {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:

1) The type of the receiver should be an interface (e.g., B) that extends the 
interface where the method is defined.
2) The receiver should be a field.



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

Reply via email to