void (@NotNull PsiTypeCastExpression expression) { PsiExpression operandExpr = expression.getOperand(); if (operandExpr == null) { throw expressionInvalid(expression); } operandExpr.accept(this); Evaluator operandEvaluator = myResult; PsiTypeElement castTypeElem = expression.getCastType(); if (castTypeElem == null) { throw expressionInvalid(expression); } PsiType castType = castTypeElem.getType(); PsiType operandType = operandExpr.getType(); // if operand type can not be resolved in current context - leave it for runtime checks if (operandType != null && !TypeConversionUtil.areTypesConvertible(operandType, castType) && PsiUtil.resolveClassInType(operandType) != null) { throw new EvaluateRuntimeException( new EvaluateException( JavaErrorBundle.message("inconvertible.type.cast", JavaHighlightUtil.formatType(operandType), JavaHighlightUtil .formatType(castType))) ); } boolean shouldPerformBoxingConversion = operandType != null && TypeConversionUtil.boxingConversionApplicable(castType, operandType); final boolean castingToPrimitive = castType instanceof PsiPrimitiveType; if (shouldPerformBoxingConversion && castingToPrimitive) { operandEvaluator = new UnBoxingEvaluator(operandEvaluator); } final boolean performCastToWrapperClass = shouldPerformBoxingConversion && !castingToPrimitive; if (!(PsiUtil.resolveClassInClassTypeOnly(castType) instanceof PsiTypeParameter)) { if (performCastToWrapperClass) { castType = ObjectUtils.notNull(PsiPrimitiveType.getUnboxedType(castType), operandType); } myResult = createTypeCastEvaluator(operandEvaluator, castType); } if (performCastToWrapperClass) { myResult = new BoxingEvaluator(myResult); } }