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 2021/11/10 15:33:00 UTC

[jira] [Updated] (GROOVY-9132) Improve type inference for method reference

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

Eric Milles updated GROOVY-9132:
--------------------------------
    Fix Version/s: 3.0.8
                   4.0.0-alpha-2
                       (was: 3.0.9)
                       (was: 4.0.0-beta-2)

> Improve type inference for method reference
> -------------------------------------------
>
>                 Key: GROOVY-9132
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9132
>             Project: Groovy
>          Issue Type: Improvement
>          Components: Static Type Checker
>            Reporter: Paul King
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 4.0.0-alpha-2, 3.0.8
>
>
> Compiling this code:
> {code}
> assert 'Hi'.transform(String::length) * 3 == 6 // transform is JDK12
> {code}
> with type checking gives:
> {noformat}
> [Static type checking] - Cannot find matching method java.lang.Object#multiply(int). Please check if the declared type is correct and if the method exists.
> {noformat}
> We can close as duplicate if this overlaps with an existing issue. It might not be anything to do with method references but an existing limitation in the type checker around supporting generics involving bounded parameters. For reference, the definition of {{transform}} is:
> {code}
> public <R> R transform​(Function<? super String,​? extends R> f)
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)