IR fix IrType.makeNullable() for DNN type

This commit is contained in:
Dmitry Petrov
2022-02-10 17:49:41 +03:00
committed by Space
parent 705d960b8f
commit f5e4c72f06
@@ -108,17 +108,28 @@ fun IrType.makeNotNull() =
kotlinType = originalKotlinType?.makeNotNullable()
hasQuestionMark = false
}
} else
} else {
this
}
fun IrType.makeNullable() =
if (this is IrSimpleType && !this.hasQuestionMark)
buildSimpleType {
kotlinType = originalKotlinType?.makeNullable()
hasQuestionMark = true
fun IrType.makeNullable(): IrType =
when (this) {
is IrSimpleType -> {
if (this.hasQuestionMark)
this
else
buildSimpleType {
kotlinType = originalKotlinType?.makeNullable()
hasQuestionMark = true
}
}
else
this
is IrDefinitelyNotNullType -> {
// '{ T & Any }?' => 'T?'
this.original.makeNullable()
}
else ->
this
}
@ObsoleteDescriptorBasedAPI
fun IrType.toKotlinType(): KotlinType {