do not report weaker access assignability higher in the hierarchy (IDEA-137533)

This commit is contained in:
Anna Kozlova
2015-03-13 14:32:10 +01:00
parent 3ae288688d
commit 1bf1a2cc13
3 changed files with 20 additions and 0 deletions
@@ -88,6 +88,7 @@ public class HighlightMethodUtil {
PsiMethod superMethod = superMethodSignature.getMethod();
if (method.hasModifierProperty(PsiModifier.ABSTRACT) && !MethodSignatureUtil.isSuperMethod(superMethod, method)) continue;
if (!PsiUtil.isAccessible(containingFile.getProject(), superMethod, method, null)) continue;
if (!includeRealPositionInfo && MethodSignatureUtil.isSuperMethod(superMethod, method)) continue;
HighlightInfo info = isWeaker(method, modifierList, accessModifier, accessLevel, superMethod, includeRealPositionInfo);
if (info != null) return info;
}
@@ -0,0 +1,15 @@
class F {
public void f() {}
}
class E extends F {
@Override
<error descr="'f()' in 'E' clashes with 'f()' in 'F'; attempting to assign weaker access privileges ('protected'); was 'public'">protected</error> void f() {
super.f();
}
}
class EE extends E {
}
@@ -467,6 +467,10 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);
}
public void testDontReportWeakerVisibilityProblemUpInHierarchy() throws Exception {
doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);
}
public void testJavaUtilCollections_NoVerify() throws Exception {
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));
assertNotNull(collectionsClass);