Summary: | [1.5][compiler] Two interfaces with methods with compatible return types are compatible | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Olivier Thomann <Olivier_Thomann> |
Component: | Core | Assignee: | Kent Johnson <kent_johnson> |
Status: | VERIFIED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | philippe_mulet |
Version: | 3.1 | ||
Target Milestone: | 3.1 M5 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: |
Description
Olivier Thomann
2004-12-10 19:27:50 EST
Expression#checkCastTypeCompatibility need to be tuned to support covariance/substitution. Need some entry point in method verifier. Philippe: So what question do you need to ask? In this block of code near the bottom of the cast compatibility rules, we are checking whether the 2 interfaces are cast compatible: ... for (int j = 0; j < exprMethodsLength; j++) { if ((castTypeMethods[i].returnType != expressionTypeMethods[j].returnType) && (CharOperation.equals(castTypeMethods[i].selector, expressionTypeMethods[j].selector)) && castTypeMethods[i].areParametersEqual(expressionTypeMethods[j])) { return false; ... these rules obviously do not play the 1.5 semantics. Please check how JLS3 have evolved on this very topic. I suspect you need to compare methods in a similar way to what method verifier does when determining if one overrides another one. Added MethodVerify test033 Actually, rules are even simpler. We always allow cast to interface from 1.5 on (a subtype may implement it). Verified in I20050215-2300 |