Community
Participate
Working Groups
When trying to compile the following piece of code #### import java.util.ArrayList; class Class<A> { ArrayList<A> list = new ArrayList<A>(); ArrayList<? super A> superList = new ArrayList<A>(); ArrayList<? extends A> extendsList = new ArrayList<A>(); ArrayList<A> getList() { return true ? list : list; } ArrayList<? super A> getSuperList() { return true ? superList : superList; } ArrayList<? extends A> getExtendsList() { return true ? extendsList : extendsList; } } #### RC3 and RC4 shows for the conditional expression in getSuperList the error "Type mismatch: cannot convert from ArrayList<capture-of ? extends Object> to ArrayList<? super A>" and for the conditional expression in getExtendsList the error "Type mismatch: cannot convert from ArrayList<capture- of ? extends Object> to ArrayList<? extends A>". When compiling the same code with javac, only the method getSuperList is marked to be incorrect: Class.java:14: incompatible types found : java.util.ArrayList<capture of ? extends java.lang.Object> required: java.util.ArrayList<? super A> return true ? superList : superList; ^ 1 error but the method getExtendsList compiles without errors.
Added GenericTypeTest#test803 *** This bug has been marked as a duplicate of 105531 ***