FIR+JVM_IR DNN-related fixes

This commit is contained in:
Dmitry Petrov
2022-02-10 14:29:24 +03:00
committed by Space
parent 412194dd75
commit 7b18d69f5f
3 changed files with 15 additions and 9 deletions
@@ -1134,11 +1134,13 @@ private fun getContainingDeclaration(declaration: IrDeclaration): DeclarationDes
fun IrType.toIrBasedKotlinType(): KotlinType = when (this) {
is IrSimpleType ->
makeKotlinType(classifier, arguments, hasQuestionMark)
is IrDefinitelyNotNullType ->
DefinitelyNotNullType.makeDefinitelyNotNull(this.original.toIrBasedKotlinType().unwrap())
?: throw AssertionError("Can't reconstruct a definitely not-null type: ${this.render()}")
is IrDefinitelyNotNullType -> {
val kotlinType = this.original.toIrBasedKotlinType()
DefinitelyNotNullType.makeDefinitelyNotNull(kotlinType.unwrap())
?: kotlinType
}
else ->
TODO(toString())
throw AssertionError("Unexpected type: $this = ${this.render()}")
}
private fun makeKotlinType(
@@ -70,3 +70,9 @@ fun IrType.toArrayOrPrimitiveArrayType(irBuiltIns: IrBuiltIns): IrType =
} else {
irBuiltIns.arrayClass.typeWith(this)
}
fun IrType.unwrapDefinitelyNotNullType(): IrType =
if (this is IrDefinitelyNotNullType)
this.original.unwrapDefinitelyNotNullType()
else
this