| Summary: | [1.5][compiler] Conditional expressions get confused by generic types | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Tobias Riemenschneider <tobys> |
| Component: | Core | Assignee: | Philipe Mulet <philippe_mulet> |
| Status: | RESOLVED DUPLICATE | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | ||
| Version: | 3.1 | ||
| Target Milestone: | 3.1.1 | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
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.