prefer generics to raw when more specific was not detected (IDEA-67576)

This commit is contained in:
Anna Kozlova
2013-08-15 13:49:50 +04:00
parent c5e3693ce2
commit 215cfff69c
3 changed files with 29 additions and 6 deletions
@@ -502,12 +502,10 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
int level2 = getLevel(applicabilityLevel, languageLevel, method2, typeParameters2, types1, types2, resolveHelper);
if (level1 > level2) return Specifics.SECOND;
if (level2 > level1) return Specifics.FIRST;
if (level1 == MethodCandidateInfo.ApplicabilityLevel.NOT_APPLICABLE) {
final boolean raw1 = PsiUtil.isRawSubstitutor(method1, classSubstitutor1);
final boolean raw2 = PsiUtil.isRawSubstitutor(method2, classSubstitutor2);
if (raw1 ^ raw2) {
return raw1 ? Specifics.SECOND : Specifics.FIRST;
}
final boolean raw1 = PsiUtil.isRawSubstitutor(method1, classSubstitutor1);
final boolean raw2 = PsiUtil.isRawSubstitutor(method2, classSubstitutor2);
if (raw1 ^ raw2) {
return raw1 ? Specifics.SECOND : Specifics.FIRST;
}
}
else if (applicabilityLevel == MethodCandidateInfo.ApplicabilityLevel.VARARGS) {
@@ -0,0 +1,21 @@
package pck;
interface A<T>
{
<S> T foo();
}
interface B
{
<S> Object foo();
}
interface C extends A, B { }
class D
{
void bar(C x)
{
x.foo();
}
}
@@ -207,6 +207,10 @@ public class AdvHighlightingJdk7Test extends DaemonAnalyzerTestCase {
doTestAmbiguous();
}
public void testAmbiguousIDEA67576() throws Exception {
doTestAmbiguous();
}
public void testAmbiguousMethodsFromSameClassAccess() throws Exception {
doTestAmbiguous();
}