diff --git a/java/codeserver/highlighting/src/com/intellij/java/codeserver/highlighting/ExpressionChecker.java b/java/codeserver/highlighting/src/com/intellij/java/codeserver/highlighting/ExpressionChecker.java index 2013e2d0d7f1..97f8a8b6efd1 100644 --- a/java/codeserver/highlighting/src/com/intellij/java/codeserver/highlighting/ExpressionChecker.java +++ b/java/codeserver/highlighting/src/com/intellij/java/codeserver/highlighting/ExpressionChecker.java @@ -1668,9 +1668,12 @@ final class ExpressionChecker { PsiClass parentClass = constructor.getContainingClass(); if (parentClass == null) return; - // references to private methods from the outer class are not calls to super methods + // references to private methods and fields from the outer class are not calls to super methods // even if the outer class is the superclass - if (resolved instanceof PsiMember member && member.hasModifierProperty(PsiModifier.PRIVATE) && referencedClass != parentClass) return; + if (resolved instanceof PsiMember member && member.hasModifierProperty(PsiModifier.PRIVATE) && + referencedClass != parentClass && !(member instanceof PsiClass)) { + return; + } // field or method should be declared in this class or super if (!InheritanceUtil.isInheritorOrSelf(parentClass, referencedClass, true)) return; // and point to our instance diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting8/ReferenceToPrivateClass.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting8/ReferenceToPrivateClass.java new file mode 100644 index 000000000000..a6454e0e243a --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting8/ReferenceToPrivateClass.java @@ -0,0 +1,39 @@ +class A { + A(C c) {} + + static class B extends A { + B() { + super(new C()); + } + + B(int x) { + super(getC()); + } + + B(double x) { + super(c); + } + } + + class B1 extends A { + B1() { + super(new C()); + } + + B1(int x) { + super(getC()); + } + + B1(double x) { + super(c); + } + } + + private C getC() { + return new C(); + } + + private C c = new C(); + + private class C {} +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/LightAdvHighlightingJdk8Test.java b/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/LightAdvHighlightingJdk8Test.java index db01f3f2290c..516f516e17c9 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/LightAdvHighlightingJdk8Test.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/LightAdvHighlightingJdk8Test.java @@ -49,4 +49,5 @@ public class LightAdvHighlightingJdk8Test extends LightDaemonAnalyzerTestCase { doTest(true, true); } public void testCyclicInheritanceOfTypeAnnotation() { doTest(true, true); } + public void testReferenceToPrivateClass() { doTest(true, true); } } \ No newline at end of file