diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypes.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypes.kt index 8c1fb9423db..4660d0d13e9 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypes.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypes.kt @@ -55,18 +55,24 @@ fun IrType.makeNullable() = else this -fun IrType.toKotlinType(): KotlinType = when (this) { - is IrSimpleType -> { - val classifier = this.classifier.descriptor - val arguments = this.arguments.mapIndexed { index, it -> - when (it) { - is IrTypeProjection -> TypeProjectionImpl(it.variance, it.type.toKotlinType()) - is IrStarProjection -> StarProjectionImpl((classifier as ClassDescriptor).declaredTypeParameters[index]) - else -> error(it) - } - } - - classifier.defaultType.replace(newArguments = arguments).makeNullableAsSpecified(this.hasQuestionMark) +fun IrType.toKotlinType(): KotlinType { + originalKotlinType?.let { + return it + } + + return when (this) { + is IrSimpleType -> { + val classifier = classifier.descriptor + val arguments = arguments.mapIndexed { index, it -> + when (it) { + is IrTypeProjection -> TypeProjectionImpl(it.variance, it.type.toKotlinType()) + is IrStarProjection -> StarProjectionImpl((classifier as ClassDescriptor).declaredTypeParameters[index]) + else -> error(it) + } + } + + classifier.defaultType.replace(newArguments = arguments).makeNullableAsSpecified(hasQuestionMark) + } + else -> TODO(toString()) } - else -> TODO(this.toString()) }