You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2024/03/05 01:54:00 UTC

[jira] [Closed] (GROOVY-11259) STC loses generic information on method references

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

Paul King closed GROOVY-11259.
------------------------------

> STC loses generic information on method references
> --------------------------------------------------
>
>                 Key: GROOVY-11259
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11259
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>    Affects Versions: 4.0.17
>            Reporter: Christopher Smith
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 4.0.18, 3.0.21
>
>
> In the following code, the correct return type of {{Map.Entry::getKey}} is {{K = String}}, but the STC loses track of it and returns {{Object}}, leading to downstream type mismatches.
> {code:groovy}
> @CompileStatic
> class Repro {
>     void repro(Map<String, String> input) {
>         var keys = input.entrySet().stream()
>             .map(Map.Entry::getKey)
>             .toSet()
>         consume(keys)
>     }
>     static void consume(Set<String> keys) {}
> }
> {code}



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