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