Community
Participate
Working Groups
The following code generates an error in eclipse 3.1.1 and 3.1m2, but it compiles fine in both eclipse 3.1 and javac version 1.5.0_05. It doesn't matter if the "Interface" class below is defined as a class or as an interface, it generates the error in both cases. The error is: "Type mismatch: cannot convert from List<Object> to List<? extends Test.Interface>" import java.util.Collections; import java.util.List; public class Test { public interface Interface { // nothing } public List<? extends Interface> field = Collections.emptyList(); }
A workaround that doesn't involve suppressing warnings is to explicitly supply the extended type: public List<? extends Interface> field = Collections.<Interface>emptyList();
A patch for 3.1.1 is available, see some comment in bug 112268. Added regression test: GenericTypeTest#test866 *** This bug has been marked as a duplicate of 112268 ***
Verified in M20060109-0800 for 3.1.2