Map nullable type parameter with nullable inline class upper bound

which, in turn, has primitive or nullable underlying type to inline
class.
 #KT-32162
This commit is contained in:
Ilmir Usmanov
2021-12-30 16:52:38 +01:00
parent e8977d77e6
commit a7e2f7a6b6
4 changed files with 23 additions and 14 deletions
@@ -21,14 +21,18 @@ private fun TypeSystemCommonBackendContext.computeExpandedTypeInner(
val typeParameter = classifier.getTypeParameterClassifier()
return when {
typeParameter != null ->
computeExpandedTypeInner(typeParameter.getRepresentativeUpperBound(), visitedClassifiers)
typeParameter != null -> {
val upperBound = typeParameter.getRepresentativeUpperBound()
computeExpandedTypeInner(upperBound, visitedClassifiers)
?.let { expandedUpperBound ->
if (expandedUpperBound.isNullableType() || !kotlinType.isMarkedNullable())
expandedUpperBound
else
expandedUpperBound.makeNullable()
when {
expandedUpperBound is SimpleTypeMarker && expandedUpperBound.isPrimitiveType() &&
kotlinType.isNullableType() && upperBound.typeConstructor().isInlineClass() -> upperBound.makeNullable()
expandedUpperBound.isNullableType() || !kotlinType.isMarkedNullable() -> expandedUpperBound
else -> expandedUpperBound.makeNullable()
}
}
}
classifier.isInlineClass() -> {
// kotlinType is the boxed inline class type