Summary: | [1.5][Compiler] Inconsistency with javac: subclass does not properly inherit generic method | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Alex Kinneer <alkinneer> |
Component: | Core | Assignee: | Kent Johnson <kent_johnson> |
Status: | VERIFIED FIXED | QA Contact: | |
Severity: | major | ||
Priority: | P3 | CC: | daniel_megert, maxime_daniel, philippe_mulet |
Version: | 3.2.2 | ||
Target Milestone: | 3.3.1 | ||
Hardware: | PC | ||
OS: | Linux | ||
Whiteboard: |
Description
Alex Kinneer
2007-06-22 15:23:12 EDT
Reproduced with 3.3RC4. javac 1.5.0_12 reports: CatShopImpl.java:4: warning: getPets() in CatShopImpl implements <V>getPets() in CatShop; return type requires unchecked conversion found : java.util.List<Pet> required: java.util.List<? extends Cat> public List<Pet> getPets() { ^ PurebredCatShopImpl.java:1: warning: getPets() in CatShopImpl implements <V>getPets() in CatShop; return type requires unchecked conversion found : java.util.List<Pet> required: java.util.List<? extends Cat> public class PurebredCatShopImpl extends CatShopImpl implements PurebredCatShop { ^ PurebredCatShopImpl.java:1: warning: getPets() in CatShopImpl implements <V>getPets() in CatShop; return type requires unchecked conversion found : java.util.List<Pet> required: java.util.List<? extends Cat> public class PurebredCatShopImpl extends CatShopImpl implements PurebredCatShop { ^ 3 warnings We report: ---------- 1. WARNING in D:\tests_sources\194034\CatShopImpl.java (at line 4) public List<Pet> getPets() { ^^^^ Type safety: The return type List<Pet> for getPets() from the type CatShopImpl needs unchecked conversion to conform to List<? extends Cat> from the type CatShop ---------- ---------- 2. ERROR in D:\tests_sources\194034\PurebredCatShopImpl.java (at line 1) public class PurebredCatShopImpl extends CatShopImpl implements PurebredCatShop { ^^^^^^^^^^^^^^^^^^^ The return type is incompatible with CatShop.getPets(), CatShopImpl.getPets() ---------- 2 problems (1 error, 1 warning) Our error is reported against the class that implements the interface method while being compatible with the inherited superclass method... just as javac reports a warnining against the same class. It appears we need to need to handle this case a type conversion warning instead of a type incompatibility error. Added MethodVerifyTest test144 and corrected error messages in test077a Smells like a 3.3.1 fix as well. Pls make sure to keep patches for your fixes. Released for 3.3.1 Verified for 3.4M1 using build I20070802-0800. +1 for 3.3.1 Verified for 3.3.1 using build M20070831-2000. |