void (@NotNull PsiTypeCastExpression expression) { final PsiTypeElement castTypeElement = expression.getCastType(); PsiExpression operand = expression.getOperand(); Object opValue = getStoredValue(operand); if(castTypeElement == null || opValue == null) { myResult = null; return; } PsiType castType = castTypeElement.getType(); // According to JLS 15.28 Constant Expressions, only casts to primitive types and to String type are considered constant if (!(castType instanceof PsiPrimitiveType) && !castType.equalsToText(CommonClassNames.JAVA_LANG_STRING)) { myResult = null; return; } myResult = ConstantExpressionUtil.computeCastTo(opValue, castType); }