Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.1.5
-
None
Description
The static type checker rejects the last of the 4 assignments in the following code:
@groovy.transform.CompileStatic class Foo { static void main(String... args) { List<Integer> list = [1, 2, 3] List<Integer> immutableList = [1, 2, 3].asImmutable() Map<String, Integer> map = [foo: 123, bar: 456] Map<String, Integer> immutableMap = [foo: 123, bar: 456].asImmutable() } }
with the error Incompatible generic argument types. Cannot assign java.util.Map <java.lang.Object, java.lang.Object> to: java.util.Map <String, Integer>.
The generic signature on asImmutable should be sufficient for type inference to work (as it does for the list in the 2nd assignment).