Community
Participate
Working Groups
Build 200410130800 I get the following compile error: Type mismatch: cannot convert from Set<Map.Entry<Integer,?>> to Set<Map.Entry<Integer,?>> with this class: public class Test { private Set<Map.Entry<Integer, ?>> m_values; Test(Map<Integer, ?> values) { m_values = values.entrySet(); } }
I've had several of these errors with M2 and latest integration build (I20041026). I have been able to use a cast as a workaround. Interestingly enough, the compiler reports a warning about useless cast. It never happened with "top-level" generics, bu only with "nested" generics, ie. X<A<B>>.
Thinking about it, it might have to do with inner classes.
Reproduced
Problem comes from a mismatch in wildcards, due to capture mechanism. We are comparing Set<Map.Entry<Integer, ? denoting: V from Map) with Set<Map.Entry<Integer, ? denoting: V from Map$Entry)
Ensured wildcards are properly relocated when passed around. Added regression test: GenericTypeTest#test363 Fixed
Verified for 3.1 M3 with build I200411040800
Actually, reverting previous behavior which was the proper one. Javac does actually also reject this code. The 2 wildcard occurrences could denote different types. One is relative to Entry, and one is relative to Map; as said before.