don't override protected methods from Object in interfaces (IDEA-140804)

This commit is contained in:
Anna Kozlova
2015-05-28 15:05:27 +02:00
parent 5ffbec6759
commit 719bfffcae
2 changed files with 11 additions and 3 deletions

View File

@@ -920,9 +920,12 @@ public class GenericsHighlightUtil {
}
try {
MethodSignatureBackedByPsiMethod superMethod = SuperMethodsSearch.search(method, null, true, false).findFirst();
if (superMethod != null && method.getContainingClass().isInterface() && "clone".equals(superMethod.getName())) {
final PsiClass containingClass = superMethod.getMethod().getContainingClass();
if (containingClass != null && CommonClassNames.JAVA_LANG_OBJECT.equals(containingClass.getQualifiedName())) {
if (superMethod != null && method.getContainingClass().isInterface()) {
final PsiMethod psiMethod = superMethod.getMethod();
final PsiClass containingClass = psiMethod.getContainingClass();
if (containingClass != null &&
CommonClassNames.JAVA_LANG_OBJECT.equals(containingClass.getQualifiedName()) &&
psiMethod.hasModifierProperty(PsiModifier.PROTECTED)) {
superMethod = null;
}
}

View File

@@ -16,4 +16,9 @@ class MyCloneable2 {
public Object clone() {
return null;
}
}
interface MyFinalizable {
<error descr="Method does not override method from its superclass">@Override</error> void finalize();
@Override int hashCode();
}