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:
committed by
Dmitry Petrov
parent
1c2ac364c7
commit
fa51b962b8
@@ -55,10 +55,15 @@ fun IrType.makeNullable() =
|
|||||||
else
|
else
|
||||||
this
|
this
|
||||||
|
|
||||||
fun IrType.toKotlinType(): KotlinType = when (this) {
|
fun IrType.toKotlinType(): KotlinType {
|
||||||
|
originalKotlinType?.let {
|
||||||
|
return it
|
||||||
|
}
|
||||||
|
|
||||||
|
return when (this) {
|
||||||
is IrSimpleType -> {
|
is IrSimpleType -> {
|
||||||
val classifier = this.classifier.descriptor
|
val classifier = classifier.descriptor
|
||||||
val arguments = this.arguments.mapIndexed { index, it ->
|
val arguments = arguments.mapIndexed { index, it ->
|
||||||
when (it) {
|
when (it) {
|
||||||
is IrTypeProjection -> TypeProjectionImpl(it.variance, it.type.toKotlinType())
|
is IrTypeProjection -> TypeProjectionImpl(it.variance, it.type.toKotlinType())
|
||||||
is IrStarProjection -> StarProjectionImpl((classifier as ClassDescriptor).declaredTypeParameters[index])
|
is IrStarProjection -> StarProjectionImpl((classifier as ClassDescriptor).declaredTypeParameters[index])
|
||||||
@@ -66,7 +71,8 @@ fun IrType.toKotlinType(): KotlinType = when (this) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
classifier.defaultType.replace(newArguments = arguments).makeNullableAsSpecified(this.hasQuestionMark)
|
classifier.defaultType.replace(newArguments = arguments).makeNullableAsSpecified(hasQuestionMark)
|
||||||
|
}
|
||||||
|
else -> TODO(toString())
|
||||||
}
|
}
|
||||||
else -> TODO(this.toString())
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user