Thodoris Sotiropoulos created GROOVY-11009:
----------------------------------------------

             Summary: STC resolves wrong method reference
                 Key: GROOVY-11009
                 URL: https://issues.apache.org/jira/browse/GROOVY-11009
             Project: Groovy
          Issue Type: Bug
          Components: Static Type Checker
            Reporter: Thodoris Sotiropoulos


This is probably a regression

I have the following program

{code}
import java.util.function.*;

class Main {
  static final void test() {
    final Function<Double, Double> x = Main::clone;
  }

  public static <T> T clone(T x) { return x; }

}
{code}

h3. Actual behavior

{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 5: [Static type checking] - Invalid return type: java.lang.Object 
is not convertible to java.lang.Double
 @ line 5, column 40.
       final Function<Double, Double> x = Main::clone;
                                          ^

1 error
{code}

h3. Expected behavior

Compile successfully

h3. Notes
Tested against master (commit: c4ee3ce0661eec7d633fc81281d79c8889b3dc66)

Test case adapted from:

{code}
import java.util.function.*;

class Main {
  static final void test() {
    Function<Double, Double> x = org.apache.commons.lang3.ObjectUtils::clone;
  }
}
{code}



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

Reply via email to