Christopher Smith created GROOVY-11259:
------------------------------------------

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


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)

Reply via email to