Restore nullability after type refinement along with annotations

See the issue for details

^KT-42546 Fixed
This commit is contained in:
Dmitry Savvinov
2020-10-08 16:20:56 +03:00
parent ee794f8664
commit e06ae01c0c
@@ -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<TypeConstru
private fun TypeConstructor.isExpectClass() =
declarationDescriptor?.safeAs<ClassDescriptor>()?.isExpect == true
private fun KotlinType.restoreAdditionalTypeInformation(prototype: KotlinType): KotlinType {
return TypeUtils.makeNullableAsSpecified(this, prototype.isMarkedNullable).replace(prototype.arguments)
}