You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2023/04/15 15:51:00 UTC

[jira] [Updated] (GROOVY-11009) STC resolves wrong method reference

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

Eric Milles updated GROOVY-11009:
---------------------------------
    Priority: Minor  (was: Major)

> 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
>            Priority: Minor
>
> 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)