method conflicts resolution (IDEA-87672)

This commit is contained in:
anna
2012-07-05 16:13:22 +02:00
parent d18b86df35
commit 89653cb1f1
3 changed files with 34 additions and 7 deletions
@@ -498,9 +498,15 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
PsiSubstitutor classSubstitutor2,
PsiType type1,
PsiType type2) {
final PsiClass aClass1 = PsiUtil.resolveClassInClassTypeOnly(type1);
final PsiClass aClass2 = PsiUtil.resolveClassInClassTypeOnly(type2);
if (aClass1 instanceof PsiTypeParameter && aClass2 instanceof PsiTypeParameter) {
return checkTypeParams(method1, method2, classSubstitutor1, classSubstitutor2, type1, type2, (PsiTypeParameter)aClass1, (PsiTypeParameter)aClass2);
}
if (aClass1 instanceof PsiTypeParameter || aClass2 instanceof PsiTypeParameter) return null;
final Map<PsiTypeParameter, PsiType> map1 = classSubstitutor1.getSubstitutionMap();
final Map<PsiTypeParameter, PsiType> map2 = classSubstitutor2.getSubstitutionMap();
if (map1.size() == 1 && map2.size() == 1) {
final PsiType t1 = map1.values().iterator().next();
final PsiType t2 = map2.values().iterator().next();
@@ -517,12 +523,6 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
final PsiTypeParameter p2 = map2.keySet().iterator().next();
return checkTypeParams(method1, method2, classSubstitutor1, classSubstitutor2, type1, type2, p1, p2);
}
} else {
final PsiClass aClass1 = PsiUtil.resolveClassInClassTypeOnly(type1);
final PsiClass aClass2 = PsiUtil.resolveClassInClassTypeOnly(type2);
if (aClass1 instanceof PsiTypeParameter && aClass2 instanceof PsiTypeParameter) {
return checkTypeParams(method1, method2, classSubstitutor1, classSubstitutor2, type1, type2, (PsiTypeParameter)aClass1, (PsiTypeParameter)aClass2);
}
}
return null;
}
@@ -0,0 +1,23 @@
package pck;
class BaseMatcher<T> {
}
class MyMatcher extends BaseMatcher<String> {
}
class Expectations {
public <T> T with(T t) {
System.out.println("T");
return null;
}
public <T> T with(BaseMatcher<T> m) {
return null;
}
public static void main(String[] args) {
MyMatcher t = new MyMatcher();
String w = new Expectations().with( t);
}
}
@@ -188,4 +188,8 @@ public class AdvHighlightingJdk7Test extends DaemonAnalyzerTestCase {
public void testAmbiguousInferenceOrder() throws Exception {
doTestAmbiguous();
}
public void testAmbiguousIDEA87672() throws Exception {
doTestAmbiguous();
}
}