[psi] add parenthesis around a nullable functional type text

^KT-64862 fixed
This commit is contained in:
Anna Kozlova
2024-01-10 21:01:30 +01:00
committed by Space Team
parent c3a61f539b
commit 82d52ef6fc
@@ -103,7 +103,20 @@ class KtTypeReference : KtModifierListOwnerStub<KotlinPlaceHolderStub<KtTypeRefe
}
}
is KtIntersectionType -> getTypeText(typeElement.getLeftTypeRef()?.typeElement) + " & " + getTypeText(typeElement.getRightTypeRef()?.typeElement)
is KtNullableType -> getTypeText(typeElement.innerType) + "?"
is KtNullableType -> {
val innerType = typeElement.innerType
buildString {
val parenthesisRequired = innerType is KtFunctionType
if (parenthesisRequired) {
append("(")
}
append(getTypeText(innerType))
append("?")
if (parenthesisRequired) {
append(")")
}
}
}
null -> null
else -> error("Unsupported type $typeElement")
}