void (@NotNull PsiReferenceExpression expression) { super.visitReferenceExpression(expression); if (expression.isQualified()) { return; } final PsiElement target = expression.resolve(); if (target == null) { return; } if (!(target instanceof PsiField field)) { return; } final PsiClass fieldClass = field.getContainingClass(); if (fieldClass == null) { return; } PsiClass containingClass = ClassUtils.getContainingClass(expression); if (containingClass == null) { return; } if (!containingClass.isInheritor(fieldClass, true)) { return; } final PsiElement parent = containingClass.getParent(); if (parent instanceof PsiFile) { return; } final PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(expression.getProject()).getResolveHelper(); final String referenceText = expression.getText(); final PsiVariable variable = resolveHelper.resolveAccessibleReferencedVariable(referenceText, parent); if (variable == null || field == variable) { return; } if (expression.advancedResolve(false).getCurrentFileResolveScope() instanceof PsiImportStaticStatement) { // is statically imported return; } registerError(expression, fieldClass, variable, isOnTheFly()); }