Summary: | [compiler][1.5] compiler allows adding Object to List<? super Number> | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Tom Hofmann <eclipse> |
Component: | Core | Assignee: | Philipe Mulet <philippe_mulet> |
Status: | VERIFIED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | dirk_baeumer, markus.kell.r, trevor |
Version: | 3.1 | ||
Target Milestone: | 3.1 M5 | ||
Hardware: | PC | ||
OS: | Linux-GTK | ||
Whiteboard: |
Description
Tom Hofmann
2005-01-21 09:42:43 EST
Philippe, I encounter the same problem when implementing assigment compatibility accross contexts. I fixed it by distingusish between isAssignmentCompatible and isTypeArgumentCompatible because both need different rules: List<? extens Number>= List<Integer> but ? extends Number != Integer List<? super Number>= List<Object> but ? super Number != Object Another case: public class A<T extends Number> { List<? super T> lhs; List<? extends Number> rhs; { lhs.add(rhs.get(0)); } } Javac rejects this Another case: public class A<U extends Number> { List<? super Number> lhs; List<? super U> rhs; { lhs.add(rhs.get(0)); } } public class A<U extends Number> { List<? super Integer> lhs; List<? extends Number> rhs; { lhs.add(rhs.get(0)); } } import java.util.List; public class A<U extends Number> { List<? super Number> lhs; List<? super Integer> rhs; { lhs.add(rhs.get(0)); } } Added GenericTypeTest#test475-481. Problem comes from wrong wildcard SUPER bound check implementation. Indeed the parameterized type compared ok. Fixed, thanks for all test cases (all exposing the same one issue) *** Bug 84091 has been marked as a duplicate of this bug. *** Verified in I20050214 |