String (@NotNull PsiExpression expression) { PsiType expectedType = ExpectedTypeUtils.findExpectedType(expression, true); PsiType realType = expression.getType(); if (expectedType != null && realType != null) { for (PsiType type: getAllAssignableSupertypes(realType, expectedType)) { if (isAccessibleType(type)) { return type.getCanonicalText(); } } } return null; }