void (@NotNull GrTypeCastExpression expression) { super.visitCastExpression(expression); // visitExpression final GrExpression operand = expression.getOperand(); if (operand == null) return; final PsiType actualType = operand.getType(); if (actualType == null) return; if (expression.getCastTypeElement() == null) return; final PsiType expectedType = expression.getCastTypeElement().getType(); final ConversionResult result = TypesUtil.canCast(expectedType, actualType, expression); if (result == ConversionResult.OK) return; final ProblemHighlightType highlightType = result == ConversionResult.ERROR ? ProblemHighlightType.GENERIC_ERROR : ProblemHighlightType.GENERIC_ERROR_OR_WARNING; final String message = GroovyBundle.message( "cannot.cast", actualType.getPresentableText(), expectedType.getPresentableText() ); registerError( expression, highlightType, message ); }