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

Paul King closed GROOVY-7141.
-----------------------------

> Static type checker does not recognize closure input parameter when 
> implementing an interface with a map
> --------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-7141
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7141
>             Project: Groovy
>          Issue Type: Improvement
>          Components: Static Type Checker
>    Affects Versions: 2.3.7
>            Reporter: Mauro Molinari
>            Assignee: Eric Milles
>            Priority: Minor
>             Fix For: 3.0.14, 2.5.20, 4.0.7
>
>
> Consider the following Groovy class:
> {code}
> package e
> import groovy.transform.TypeChecked;
> @TypeChecked
> class E {
>       
>       interface MyInt {
>               String doSomething(String text)
>       }
>       
>       static void main(String[] args) {
>               MyInt impl = [
>                       doSomething: { it.toUpperCase() }
>                       ] as MyInt
>               println impl.doSomething('foo')
>       }
> }
> {code}
> The compiler complains that:
> {noformat}
> Groovy:[Static type checking] - Cannot find matching method 
> java.lang.Object#toUpperCase(). Please check if 
>  the declared type is right and if the method exists.
> {noformat}
> However I think Groovy should be smart enough to recognize that {{it}} is of 
> type {{String}} inside the closure.



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

Reply via email to