Summary: | Use of <? extends MyClass> | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | danielbackman38 |
Component: | Core | Assignee: | Srikanth Sankaran <srikanth_sankaran> |
Status: | VERIFIED INVALID | QA Contact: | |
Severity: | enhancement | ||
Priority: | P3 | CC: | amj87.iitr, srikanth_sankaran |
Version: | 3.6.2 | ||
Target Milestone: | 3.7 M7 | ||
Hardware: | PC | ||
OS: | Windows 7 | ||
Whiteboard: |
Description
danielbackman38
2011-04-14 03:33:45 EDT
Please include some sample code that you believe should compile but that does not. Please also check the behavior with javac against your code. I presume your test case looks something like: import java.util.List; public class X { public static void foo(List<? extends X> p, List <? super X> q) { p.add(new X()); // ERROR q.add(new X()); // OK } } and p.add generates an error while q.add doesn't. This is the intended behavior. To see why consider p to be assigned a actual parameter that is a List<Y> where Y extends X. Allowing addition to X's to such a list would break type safety. Please reopen with a full test case if this is not the issue. Verified for 3.7M7. |