Community
Participate
Working Groups
The following class does not compile; it yields a "Type mismatch: cannot convert from List<Object> to List<? extends Comparator>" error. --- import java.util.*; public class Foo2 { List<? extends Comparator> getFoo() { return Collections.emptyList(); } } --- This also occurs on Windows XP 3.1.1.
Consequence of fix for bug 107079. Wonder if we should force capture before inference here, or allow inferring from wildcards; but then this would contradict spec and break bug 107079 again. Note that all return type inference scenarii are broken in similar fashion: import java.util.*; public class X { List<? extends Comparator> bar() { List<? extends Comparator> l = foo(); return foo(); } <T> List<T> foo() { return null; } }
Actually, I had missed one inference rule from the spec (A >> F, where A=G<? extends/super V> >> G<U>) on p. 459. Added support and GenericTypeTest#test841. Fixed, will backport to 3.1 maintenance stream.
Thanks Tim for the pointer in spec.
Note that in 3.1.0, code was accepted, but slightly incorrectly in the sense that T got inferred to '? extends Comparator', where it is now inferred to be 'Comparator'.
Note: workaround is to write: import java.util.*; public class Foo2 { List<? extends Comparator> getFoo() { return Collections.<Comparator>emptyList(); } }
Thanks for the immediate response. When (how?) do I get the maintenance release?
3.1.2 is scheduled early next year officially (details on eclipse roadmap). Now, we can post a patch on JDT/Core web page so you do not need to wait that long.
Perfect! Thanks again Philippe (and thanson too!)
Olivier - pls produce a preview of our 3.1.2 contribution at earliest convenience.
*** Bug 112595 has been marked as a duplicate of this bug. ***
You can get the jdt/core patch on the jdt/core web page to get it fixed before 3.1.2 is out. See http://www.eclipse.org/jdt/core/r3.1/main.html#updates
*** Bug 114997 has been marked as a duplicate of this bug. ***
Verified for 3.2M4 in I20051212-2000
Verified for 3.1.2 in M20060109-0800.
*** Bug 123390 has been marked as a duplicate of this bug. ***