Community
Participate
Working Groups
The following code triggers the completely non-sensical error Type mismatch: cannot convert from List<Bug1.Foo.Sub<?>> to List<Bug1.Foo.Sub<?>> The remedy is to fully qualify Sub, i.e., to write Foo.Sub and not Sub. -------------------------------------------------------------- import java.util.List; public class Bug1 { static <T> List<T> asList(T[] x) { return null; } static interface Foo<T> { static interface Sub<T> extends Foo<T> { static List<Sub<?>> LIST = asList(ARRAY); } static Sub<?>[] ARRAY = new Sub[] { }; } }
Reproduced. This is indeed a bug in our reference resolution. Investigating
(reproduced with head)
Implementation of JLS3: 4.5.1.1 (type argument containment) did not properly handle certain wildcard situations (which btw are not mentionned in the spec).
Actually, previous comment is not accurate. After further investigation, it appears we had an identity issue in single name resolution; hence relying on type argument containment rules to cover for it. This identity issue was being addressed by using qualified names.
Created attachment 88032 [details] Proposed patch
Added GenericTypeTest#test1250-1251 Added GenericTypeTest#test1254-1266
*** Bug 216705 has been marked as a duplicate of this bug. ***
Released for 3.4M5 Fixed
Verified for 3.4M5 using build I20080204-0010
Released fix in 3.3.x maintenance branch (post 3.3.2)
*** Bug 223334 has been marked as a duplicate of this bug. ***