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

Jochen Theodorou updated GROOVY-5881:
-------------------------------------
    Affects Version/s: 4.0.13

> Type inference breaks in longer transitive generic structures
> -------------------------------------------------------------
>
>                 Key: GROOVY-5881
>                 URL: https://issues.apache.org/jira/browse/GROOVY-5881
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>    Affects Versions: 2.0.6, 2.3.0, 2.4.0-beta-3, 4.0.13
>            Reporter: Dimitar Dimitrov
>            Priority: Major
>
> {code}
> class Test {
>     @CompileStatic
>     void printProgress(Map<Integer, Closure<String>> markers, int i) {
>         for (e in markers.entrySet()) {
>             if (i%e.key==0) { print e.value(i) ; break }
>         }
>     }
> }
> {code}
> Fails to compile with: {{Groovyc: [Static type checking] - Cannot find 
> matching method java.util.Map$Entry#value(int). Please check if the declared 
> type is right and if the method exists.}}
> The following fixes the problem, though it should not be necesarry to do 
> explicit 'call'.
> {code}
> class Test {
>     @CompileStatic
>     void printProgress(Map<Integer, Closure<String>> markers, int i) {
>         for (e in markers.entrySet()) {
>             print e.value.call(i)
>         }
>     }
> }
> {code}
> For comparison, the following passes:
> {code}
> class Test {
>     @CompileStatic
>     void printProgress(Set<Closure<String>> markers, int i) {
>         for (e in markers) {
>             print e(i)
>         }
>     }
> }
> {code}



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

Reply via email to