[ https://issues.apache.org/jira/browse/GROOVY-10613?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles closed GROOVY-10613. -------------------------------- > Fail to infer correct types for fluent method calls > --------------------------------------------------- > > Key: GROOVY-10613 > URL: https://issues.apache.org/jira/browse/GROOVY-10613 > Project: Groovy > Issue Type: Bug > Components: Static Type Checker > Affects Versions: 4.0.2 > Reporter: Daniel Sun > Priority: Major > > The following code can not run when STC is enabled: > {code:java} > import java.util.stream.Collectors; > @groovy.transform.CompileStatic > def m() { > Map<String, Integer> map = new HashMap<>(); > map.put("a", 1); > map.put("b", 2); > final Map<String, Integer> result = > map.entrySet().stream().collect(Collectors.toMap(e -> e.getKey(), > e -> e.getValue(), (v1, v2) -> v1)); > return result; > } > assert [a:1, b:2] == m(); > {code} > Here are the error messages: > {code:java} > 3 compilation errors: > [Static type checking] - Cannot find matching method > java.lang.Object#getKey(). Please check if the declared type is correct and > if the method exists. > at line: 10, column: 67 > [Static type checking] - Cannot find matching method > java.lang.Object#getValue(). Please check if the declared type is correct and > if the method exists. > at line: 10, column: 84 > [Static type checking] - Incompatible generic argument types. Cannot assign > java.util.Map<java.lang.Object, java.lang.Object> to: > java.util.Map<java.lang.String, java.lang.Integer> > at line: 10, column: 13 > {code} -- This message was sent by Atlassian Jira (v8.20.7#820007)