Community
Participate
Working Groups
Build Identifier: 20100917-0705 Eclipse is marking as error the following: Collection<Comparable<?>> b = new HashSet<Comparable<Number>>(); The error is: Type mismatch: cannot convert from HashSet<Comparable<Number>> to Collection<Comparable<?>>. Interestingly, the following has no error: Comparable<?> a = new Comparable<Number>() { public int compareTo(Number o) { return 0; } }; Please also note that both the above snippets compile fine in 1.6.0_22. Reproducible: Always
Srikanth, please investigate.
I'm sorry, but I was incorrect in that it compiled in 1.6.0_22. This leads me to believe that it is user error, not an Eclipse bug.
As you have discovered, this is the intended behavior. You may want to get hold of a good tutorial: http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf is a good one. "In general, if Foo is a subtype (subclass or subinterface) of Bar, and G is some generic type declaration, it is not the case that G<Foo> is a subtype of G<Bar>." Resolving as INVALID.
Verified for 3.7M6