IR: return original KotlinType from IrTupe.toKotlinType() when it possible instead of creating new one

(cherry picked from commit e3b921a)
This commit is contained in:
Zalim Bashorov
2018-06-24 01:41:39 +03:00
committed by Dmitry Petrov
parent 1c2ac364c7
commit fa51b962b8
@@ -55,18 +55,24 @@ fun IrType.makeNullable() =
else else
this this
fun IrType.toKotlinType(): KotlinType = when (this) { fun IrType.toKotlinType(): KotlinType {
is IrSimpleType -> { originalKotlinType?.let {
val classifier = this.classifier.descriptor return it
val arguments = this.arguments.mapIndexed { index, it -> }
when (it) {
is IrTypeProjection -> TypeProjectionImpl(it.variance, it.type.toKotlinType()) return when (this) {
is IrStarProjection -> StarProjectionImpl((classifier as ClassDescriptor).declaredTypeParameters[index]) is IrSimpleType -> {
else -> error(it) val classifier = classifier.descriptor
} val arguments = arguments.mapIndexed { index, it ->
} when (it) {
is IrTypeProjection -> TypeProjectionImpl(it.variance, it.type.toKotlinType())
classifier.defaultType.replace(newArguments = arguments).makeNullableAsSpecified(this.hasQuestionMark) 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())
} }