Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Won't Fix
-
Affects Version/s: None
-
Fix Version/s: 1.6.3
-
Component/s: None
-
Labels:None
-
Environment:windows xp
-
Number of attachments :
Description
After a declaration of a collection with generics, the wrong types are inserted and accepted, even if the generics are also explicitly declared in the constructor. Code to reproduce it:
Map<String, Integer> map = [:]
map["foo"] = "bar"
println "map = $map"
Map<String, Integer> map2 = new HashMap<String, Integer>()
map2.put("foo", "bar")
println "map2 = $map2"
Output:
map = [foo:bar]
map2 = [foo:bar]
Generics in Groovy are mostly a feature for compatibility with Java. You can use them yes, but only what is left after type erasure is really checked. In your case that is nothing.