Summary: | [1.5] [compiler] Error in type checking for generics | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Konstantin Titorenko <titorenko> |
Component: | Core | Assignee: | Kent Johnson <kent_johnson> |
Status: | VERIFIED INVALID | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | Olivier_Thomann, srikanth_sankaran, stephan.herrmann |
Version: | 3.5 | ||
Target Milestone: | 3.6 M1 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: |
Description
Konstantin Titorenko
2009-07-28 13:47:12 EDT
(In reply to comment #0) > 2. Compile same code with Sun javac -> error I don't see any error when compiling with Sun javac. I have javac 1.6.0_13, which version were you using? Indeed, it compiles on 1.6.0_14. The error appears for sure on 1.5.0_12 and on 1.5.0_19: javac -version Test.java javac 1.5.0_19 Test.java:3: doStuff(IGenericReference<? extends ISpecificReference>) in Delegate cannot be applied to (IGenericReference<capture of ? extends ISpecificReference>) new Delegate().doStuff(reference); ^ 1 error Code is unfortunatelly quite complicated, not sure now if it was a genuine error in eclipse compiler. If you don't see any problem with code, please resolve the bug (as invalid, I guess). OK, slightly modified code doesn't compile on 1.6.0_14, but still compiles on eclipse: public class Test { void doStuff(GenericReference<? extends SpecificReference> reference) { new Delegate().doStuff(reference); } } class Delegate { void doStuff(GenericReference<? extends SpecificReference> reference) { } } class GenericReference<T extends GenericReference<T>> {} class SpecificReference {} Logically, it looks like 1.6 working correct. In previous version SpecificReference was an interface and it was possible for some type to implement both Specific and Generic one (1.5 has not accounted for that), but for classes it is not possible (eclipse compiler has not accounted for that). Sorry, ignore previous posting eclipse compiler works in the same way as Sun 1.6 Problem is only on 1.5 versions. Compiles fine with javac 6 & 7, and eclipse Believe this was a bug in 1.5 Verified for 3.6M1 |