Match (PsiReferenceExpression referenceExpression1, PsiReferenceExpression referenceExpression2) { final PsiElement element1 = referenceExpression1.resolve(); final PsiElement element2 = referenceExpression2.resolve(); if (element1 != null) { if (element2 == null || !equivalentDeclarations(element1, element2)) { return EXACT_MISMATCH; } } else { return EXACT_MISMATCH; // incomplete code } if (element1 instanceof PsiMember member1) { if (member1.hasModifierProperty(PsiModifier.STATIC)) { return EXACT_MATCH; } if (member1 instanceof PsiClass) { return EXACT_MATCH; } } else { return EXACT_MATCH; } PsiClass target1 = getQualifierTarget(referenceExpression1); PsiClass target2 = getQualifierTarget(referenceExpression2); if (target1 != null || target2 != null) { if (target1 == null || target2 == null) return EXACT_MISMATCH; return Match.exact(equivalentDeclarations(target1, target2)); } final PsiExpression qualifier1 = PsiUtil.skipParenthesizedExprDown(referenceExpression1.getQualifierExpression()); final PsiExpression qualifier2 = PsiUtil.skipParenthesizedExprDown(referenceExpression2.getQualifierExpression()); if (qualifier1 == null || qualifier2 == null) { return Match.exact(qualifier1 == qualifier2); } Match match = expressionsMatch(qualifier1, qualifier2); if (!match.isExactMatch() && PsiUtil.isArrayClass(((PsiMember)element1).getContainingClass()) && !(GenericsUtil.getLeastUpperBound(qualifier1.getType(), qualifier2.getType(), referenceExpression1.getManager()) instanceof PsiArrayType)) { // access to the member (length or clone()) of incompatible arrays return EXACT_MISMATCH; } if (match.isExactMismatch()) { return new Match(qualifier1, qualifier2); } return match; }