Correctly map nullable generic underlying value of inline class

if upper bound is primitive type.
 #KT-32162
This commit is contained in:
Ilmir Usmanov
2022-01-03 14:59:21 +01:00
parent 71729ec43c
commit 2fedb97d16
17 changed files with 478 additions and 4 deletions
@@ -25,9 +25,11 @@ private fun TypeSystemCommonBackendContext.computeExpandedTypeInner(
val upperBound = typeParameter.getRepresentativeUpperBound()
computeExpandedTypeInner(upperBound, visitedClassifiers)
?.let { expandedUpperBound ->
val upperBoundIsPrimitiveOrInlineClass =
upperBound.typeConstructor().isInlineClass() || upperBound is SimpleTypeMarker && upperBound.isPrimitiveType()
when {
expandedUpperBound is SimpleTypeMarker && expandedUpperBound.isPrimitiveType() &&
kotlinType.isNullableType() && upperBound.typeConstructor().isInlineClass() -> upperBound.makeNullable()
kotlinType.isNullableType() && upperBoundIsPrimitiveOrInlineClass -> upperBound.makeNullable()
expandedUpperBound.isNullableType() || !kotlinType.isMarkedNullable() -> expandedUpperBound
else -> expandedUpperBound.makeNullable()
}