void (@NotNull PsiReferenceExpression expression) { PsiExpression qualifier = deparenthesizeExpression(expression.getQualifierExpression()); if (qualifier instanceof PsiTypeCastExpression typeCast) { PsiExpression operand = getInnerMostOperand(typeCast.getOperand()); if (operand == null) return; PsiTypeElement typeElement = typeCast.getCastType(); if (typeElement == null) return; PsiType opType = operand.getType(); if (opType == null) return; if (!(operand instanceof PsiFunctionalExpression || opType instanceof PsiPrimitiveType) && isCastInReferenceQualifierRedundant(expression)) { addToResults(typeCast); } } super.visitReferenceExpression(expression); }