void (@NotNull PsiInstanceOfExpression expression) { final PsiTypeElement checkTypeElement = expression.getCheckType(); if (checkTypeElement == null) return; PsiExpression typeCast = deparenthesizeExpression(expression.getOperand()); if (typeCast instanceof PsiTypeCastExpression) { PsiExpression operand = getInnerMostOperand(((PsiTypeCastExpression)typeCast).getOperand()); if (operand != null) { PsiType opType = operand.getType(); //15.20.2. Type Comparison Operator instanceof: //If a cast (p15.16) of the RelationalExpression to the ReferenceType would be rejected as a compile-time error, //then the instanceof relational expression likewise produces a compile-time error. if (opType != null && !(opType instanceof PsiPrimitiveType) && TypeConversionUtil.areTypesConvertible(opType, checkTypeElement.getType())) { addToResults((PsiTypeCastExpression)typeCast); } } } super.visitInstanceOfExpression(expression); }