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() kotlinType = originalKotlinType?.makeNotNullable()
hasQuestionMark = false hasQuestionMark = false
} }
} else } else {
this this
}
fun IrType.makeNullable() = fun IrType.makeNullable(): IrType =
if (this is IrSimpleType && !this.hasQuestionMark) when (this) {
is IrSimpleType -> {
if (this.hasQuestionMark)
this
else
buildSimpleType { buildSimpleType {
kotlinType = originalKotlinType?.makeNullable() kotlinType = originalKotlinType?.makeNullable()
hasQuestionMark = true hasQuestionMark = true
} }
else }
is IrDefinitelyNotNullType -> {
// '{ T & Any }?' => 'T?'
this.original.makeNullable()
}
else ->
this this
}
@ObsoleteDescriptorBasedAPI @ObsoleteDescriptorBasedAPI
fun IrType.toKotlinType(): KotlinType { fun IrType.toKotlinType(): KotlinType {