From 1bf1a2cc1364f107312033673f11cca63fb5240b Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 13 Mar 2015 13:32:13 +0100 Subject: [PATCH] do not report weaker access assignability higher in the hierarchy (IDEA-137533) --- .../daemon/impl/analysis/HighlightMethodUtil.java | 1 + ...eportWeakerVisibilityProblemUpInHierarchy.java | 15 +++++++++++++++ .../daemon/GenericsHighlightingTest.java | 4 ++++ 3 files changed, 20 insertions(+) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/DontReportWeakerVisibilityProblemUpInHierarchy.java diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java index deacd9209c0f..f3f35619dffa 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java @@ -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; } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/DontReportWeakerVisibilityProblemUpInHierarchy.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/DontReportWeakerVisibilityProblemUpInHierarchy.java new file mode 100644 index 000000000000..2f17edfb3e93 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/DontReportWeakerVisibilityProblemUpInHierarchy.java @@ -0,0 +1,15 @@ + +class F { + public void f() {} +} + +class E extends F { + @Override + protected void f() { + super.f(); + } +} + +class EE extends E { + +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java index b1dff9c63cbb..718518b93ec4 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java @@ -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);