Summary: | [1.5][compiler] Compiler error with generic covariant | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Divyanshu Sharma <divyanshu.sharma> | ||||||
Component: | Core | Assignee: | Philipe Mulet <philippe_mulet> | ||||||
Status: | VERIFIED FIXED | QA Contact: | |||||||
Severity: | major | ||||||||
Priority: | P3 | CC: | david_audel, jerome_lanneluc, kent_johnson | ||||||
Version: | 3.3.1 | Flags: | philippe_mulet:
pmc_approved+
|
||||||
Target Milestone: | 3.3.2 | ||||||||
Hardware: | PC | ||||||||
OS: | Windows XP | ||||||||
Whiteboard: | |||||||||
Attachments: |
|
Description
Divyanshu Sharma
2008-01-18 14:22:04 EST
Reproduced with latest. Thanks for the testcase. Our lookup seems to pick the superclass method by mistake. Lookup properly isolates the following 2 candidates: 1. X.SubInterface and(SuperInterface#RAW) 2. SuperInterface#RAW and(SuperInterface#RAW) but tiebreak (Scope#mostSpecificMethodBinding(...)) decides (2) is the best match. I believe the problem is coming from Scope#isAcceptableMethod(...) which seems to reject the scenario where both methods have identical types, and original super method argtype wasn't raw. I don't get what this test is intending to achieve. Deleting the check makes the problem go away. Didn't find any regression in existing tests. Kent - what do you think ? Created attachment 87394 [details]
Proposed patch
Oops, there is a regression in AmbiguousMethodTest#test014h. Instead of removing the 5 lines from Scope, I suggest we change it to: if (oneParam == twoParam) { if (twoParam.leafComponentType().isRawType()) { // must detect & reject this case // when Y<U> extends X<U> // void foo(Y y) {} // <T extends X<Object>> void foo(T t) {} // foo(T) will show up as foo(Y#RAW) and not foo(X#RAW) // Y#RAW is not more specific than a rawified X<T> if (twoParam.leafComponentType().erasure() != two.original().parameters[i].leafComponentType().erasure()) return false; } continue; } But now, we would fail to accept the following code: public class X { <T extends G<X>> void a3(T x) {} <T extends F<X>> void a3(T x) {} public static void ambiguousCases() { H<X> hx = null; H hraw = null; new X().a3(hx); new X().a3(hraw); } } class F<T1> {} class G<T2> extends F<T2> {} class H<T3> extends G<T3> {} Created attachment 87506 [details]
Better patch
Here is a patch which addresses the latter issue.
Added GenericTypeTest#test1232-1241. Kent - what do you think ? looks good Released for 3.4M5. Fixed This is a regression over 3.2.2. Candidating for 3.3.2. Jerome ? Asking for PMC approval to backport to 3.3.2 since: - valid code is rejected - this is a regression comparing to 3.2.2 - the fix is simple +1 for 3.3.2 Released for 3.3.2 (same patch) Fixed Verified for 3.3.2 using build M20080123-0800 Verified for 3.4M5 using I20080204-0010 |