Community
Participate
Working Groups
Against I20050527-1300. Consider the following code: >>>>> package dj.test; import java.util.Arrays; import java.util.List; import junit.framework.TestCase; public class Deejay extends TestCase { class Counter<T> { } Counter<Song> songCounter = new Counter<Song>(); Counter<Genre> genreCounter = new Counter<Genre>(); List<Counter<?>> list1 = Arrays.asList(songCounter, genreCounter); List<Counter<? extends Object>> list2 = Arrays.asList(songCounter, genreCounter); List<Counter<?>> list3 = Arrays.<Counter<?>>asList(songCounter, genreCounter); List<Counter<?>> list4 = Arrays.asList(new Counter<?>[] {songCounter, genreCounter}); } class Genre { } class Song { } <<<<< list1: compile error: Type mismatch: cannot convert from List<Deejay.Counter<? extends Object>> to List<Deejay.Counter<?>> list2: compile error: Type mismatch: cannot convert from List<Deejay.Counter<? extends Object>> to List<Deejay.Counter<? extends Object>> list3: fine list4: fine Changing Counter to static has no effect. However, moving it out of Deejay fixes the compile errors. There's something about inner parameterized types that causes the above type mismatches.
There are 2 issues in RC1. list1: compile error: Type mismatch: cannot convert from List<Deejay.Counter<? extends Object>> to List<Deejay.Counter<?>> Type argument containment should allow ? to be matching ? extends Object at depth 2. list2: compile error: Type mismatch: cannot convert from List<Deejay.Counter<? extends Object>> to List<Deejay.Counter<? extends Object>> There is one case where we did not pass along the enclosing type of the member type (in Scope#leastContainingInvocation) leading to building a different instance of List<Counter<? extends Object>. Added GenericTypeTest#test701-702. Fixed
fixed
Dirk - good example of compiler semantics evolving
Verified for 3.1 RC2 using build N20050607-0010 + JDT/Core HEAD
Verified with I20050610-0010