void (PsiTypeCastExpression typeCast, @NotNull PsiConditionalExpression parent, @Nullable PsiExpression oppositeOperand) { final PsiExpression operand = getInnerMostOperand(typeCast.getOperand()); if (operand == null) return; PsiType castTo = typeCast.getType(); if (castTo == null) return; PsiType expectedTypeByParent = PsiTypesUtil.getExpectedTypeByParent(parent); if (operand instanceof PsiFunctionalExpression && !castTo.equals(expectedTypeByParent)) { return; } PsiType opType = operand.getType(); if (opType == null) return; if (castTo instanceof PsiClassType && TypeConversionUtil.isPrimitiveAndNotNull(opType)) { if (oppositeOperand != null && !(oppositeOperand.getType() instanceof PsiPrimitiveType) && !(expectedTypeByParent instanceof PsiPrimitiveType)) { return; } } final PsiType conditionalType = parent.getType(); if (!Comparing.equal(opType, conditionalType)) { if (!PsiUtil.isLanguageLevel5OrHigher(typeCast)) { return; } if (!PsiPolyExpressionUtil.isInAssignmentOrInvocationContext(parent) || PsiPolyExpressionUtil.sameBooleanOrNumeric(operand, oppositeOperand)) { //branches need to be of the same type if (oppositeOperand == null || !Comparing.equal(conditionalType, oppositeOperand.getType())) return; } } addIfNarrowing(typeCast, opType, expectedTypeByParent); }