diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/KotlinTypeRefinerImpl.kt b/compiler/frontend/src/org/jetbrains/kotlin/types/KotlinTypeRefinerImpl.kt index 0b34268da17..fe63784aae2 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/KotlinTypeRefinerImpl.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/KotlinTypeRefinerImpl.kt @@ -67,7 +67,8 @@ class KotlinTypeRefinerImpl( val cached = refinedTypeCache.computeIfAbsent(type.constructor) { type.constructor.declarationDescriptor!!.defaultType.refine(this) } - cached.replace(type.arguments) + + cached.restoreAdditionalTypeInformation(type) } else -> type.refine(this) } @@ -146,3 +147,7 @@ private val TypeConstructor.allDependentTypeConstructors: Collection()?.isExpect == true + +private fun KotlinType.restoreAdditionalTypeInformation(prototype: KotlinType): KotlinType { + return TypeUtils.makeNullableAsSpecified(this, prototype.isMarkedNullable).replace(prototype.arguments) +}