| Summary: | [1.8][inference] Contrived Generics Fails to Compile | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Michael D <git> | ||||
| Component: | Core | Assignee: | Stephan Herrmann <stephan.herrmann> | ||||
| Status: | CLOSED NOT_ECLIPSE | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | stephan.herrmann | ||||
| Version: | 4.7 | ||||||
| Target Milestone: | 4.8 M2 | ||||||
| Hardware: | PC | ||||||
| OS: | Linux | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
Michael D
NB: An older version of ECJ (http://search.maven.org/#artifactdetails%7Corg.eclipse.tycho%7Corg.eclipse.jdt.core%7C3.11.1.v20150902-1521%7Cjar) compiles this class successfully. Thanks I can reproduce assuming you are compiling at compliance 1.8. Accepted by ecj versions up-to 4.6M5, rejected since 4.6M6. More specifically, the fix for bug 488649 causes this change. Linked from that bug I see the following related bug against javac: https://bugs.openjdk.java.net/browse/JDK-6791481 This 8 year old bug has not been resolved, not even scheduled for resolution as of today. A newer bug linked from the latter is https://bugs.openjdk.java.net/browse/JDK-8135087 scheduled for Java 10. From this it's not obvious which behavior is actually correct per JLS. I'm leaning towards saying the new ecj behavior is correct. I will re-asses after javac has fixed their known bug. To demonstrate the connection to the javac bug, see that this succeeds in ecj: concat( array( new Test[ 0 ] ), this.<ITest>method( (Iterable) list ) ); (this is still not recommended coding style). How to resolve: change the cast from (Iterable) list to (Iterable<ITest>) list This still gives an "unchecked" warning but that is unavoidable in Java, it seems. Closing (bug is in javac, not ecj) until we see evidence that ecj is indeed at fault. PS: Seeing raw types in the example, I should say that (a) type inference involving raw types is a very thorny issue, and (b) improving support for raw types is not a priority for me personally - for further reference see http://docs.oracle.com/javase/specs/jls/se8/html/jls-4.html#jls-4.8 - search for "The use of raw types". |