String (PsiExpression expression, PsiType type, PsiExpression falseExpression) { if (!(type instanceof PsiClassType)) return ""; String text = expression.getText(); // PsiEmptyExpressionImpl might be passed here if (text.isEmpty()) return ""; PsiExpression copy = JavaPsiFacade.getElementFactory(expression.getProject()).createExpressionFromText(text, expression); PsiType exprType = copy.getType(); if (exprType != null && !exprType.equals(PsiTypes.nullType()) && !LambdaUtil.notInferredType(exprType) && TypeConversionUtil.isAssignable(type, exprType)) { if (falseExpression == null) return ""; PsiType falseType = falseExpression.getType(); if (falseType != null && (falseType.isAssignableFrom(exprType) || falseType.equals(PsiTypes.nullType()))) return ""; } return "<" + type.getCanonicalText() + ">"; }