Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.3.7
-
None
Description
Consider the following Groovy class:
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') } }
The compiler complains that:
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.
However I think Groovy should be smart enough to recognize that it is of type String inside the closure.