Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.0.0
-
None
-
Ubuntu 12.04, Oracle JVM 1.7.0_05
Description
import groovy.transform.CompileStatic @CompileStatic class BrokenCompileStaticTest extends GroovyTestCase { void testMapForEachAttribute() { def result = "" def sum = 0 for ( Map.Entry<String, Integer> it in [a:1, b:3].entrySet() ) { result += it.key sum += it.value } assert result == "ab" assert sum == 4 } }
fails to infer the type of Map.Entry#key and #value, regardless of the proper generic type in the for-in loop definition.
Message:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: /home/steven/BrokenCompileStaticTest.groovy: 9: [Static type checking] - Cannot find matching method int#plus(java.lang.Object <V>) @ line 9, column 8. sum += it.value ^ 1 error
Also, shouldn't groovy report both static type errors, instead of just the first?
Attachments
Attachments
Issue Links
- depends upon
-
GROOVY-5594 Type checker doesn't infer property type if coming from a generified getter
- Closed
-
GROOVY-5595 Type checker doesn't fully infer Map.Entry type
- Closed