Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.0.6, 2.3.0, 2.4.0-beta-3, 4.0.13
-
None
Description
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 } } } }
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'.
class Test { @CompileStatic void printProgress(Map<Integer, Closure<String>> markers, int i) { for (e in markers.entrySet()) { print e.value.call(i) } } }
For comparison, the following passes:
class Test { @CompileStatic void printProgress(Set<Closure<String>> markers, int i) { for (e in markers) { print e(i) } } }
Attachments
Issue Links
- is related to
-
GROOVY-6324 Cannot call closure like a method in type checked mode
- Closed