[ https://issues.apache.org/jira/browse/GROOVY-5881 ]


    Eric Milles deleted comment on GROOVY-5881:
    -------------------------------------

was (Author: emilles):
See also GROOVY-6324

> 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
>            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.1#820001)

Reply via email to