show warning on type parameter declaration if it lead to multiple methods with same erasure (java7 only)

This commit is contained in:
anna
2012-04-08 14:05:51 +02:00
parent 74bfc88397
commit 8fe1604bd1
3 changed files with 8 additions and 2 deletions
@@ -372,6 +372,7 @@ public class GenericsHighlightUtil {
}
}
@Nullable
public static HighlightInfo checkElementInTypeParameterExtendsList(PsiReferenceList referenceList, JavaResolveResult resolveResult, PsiElement element) {
PsiClass aClass = (PsiClass)referenceList.getParent();
final PsiJavaCodeReferenceElement[] referenceElements = referenceList.getReferenceElements();
@@ -393,6 +394,11 @@ public class GenericsHighlightUtil {
IntentionAction fix = QUICK_FIX_FACTORY.createExtendsListFix(aClass, type, false);
QuickFixAction.registerQuickFixAction(errorResult, fix, null);
}
if (errorResult == null && JavaVersionService.getInstance().isAtLeast(referenceList, JavaSdkVersion.JDK_1_7) &&
referenceElements.length > 1) {
//todo suppress erased methods which come from the same class
return checkOverrideEquivalentMethods(aClass);
}
return errorResult;
}
public static HighlightInfo checkInterfaceMultipleInheritance(PsiClass aClass) {
@@ -9,7 +9,7 @@ interface IB{
<T> void foo(A<T> x);
}
class C {
<T extends IA & IB> void bar(T x, A<String> y){
<<error descr="'foo(A<T>)' in 'pck.IB' clashes with 'foo(A<?>)' in 'pck.IA'; both methods have same erasure, yet neither overrides the other"></error>T extends IA & IB> void bar(T x, A<String> y){
x.foo<error descr="Ambiguous method call: both 'IA.foo(A<?>)' and 'IB.foo(A<String>)' match">(y)</error>;
}
}
@@ -9,7 +9,7 @@ interface IB{
<T> void foo(A<? super A<T>> x);
}
class C {
<T extends IB & IA> void bar(T x, A<A<String>> y){
<<error descr="'foo(A<A<T>>)' in 'pck.IA' clashes with 'foo(A<? super A<T>>)' in 'pck.IB'; both methods have same erasure, yet neither overrides the other"></error>T extends IB & IA> void bar(T x, A<A<String>> y){
x.foo(y);
}
}