IDEA-380311 [java-highlighting] Invalid code "cannot referenced from static context" not highlighted properly in Java

(cherry picked from commit e1d8918aca30a74ffbf3d3bbf8af07c6f45b5244)

IJ-CR-194233

GitOrigin-RevId: f5918ea65adb2bf6ccae0835c52e826b88deb0ad
This commit is contained in:
Tagir Valeev
2026-03-04 10:47:55 +00:00
committed by intellij-monorepo-bot
parent 7ddee33f31
commit a4f2bd1574
3 changed files with 45 additions and 2 deletions
@@ -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