backend: fix type operator result type in autoboxing
This commit is contained in:
committed by
SvyatoslavScherbina
parent
11f2ea7e38
commit
d4fc79da43
+6
-2
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.ir.util.isNullConst
|
|||||||
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
|
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.TypeUtils
|
import org.jetbrains.kotlin.types.TypeUtils
|
||||||
|
import org.jetbrains.kotlin.types.typeUtil.makeNullable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Boxes and unboxes values of value types when necessary.
|
* Boxes and unboxes values of value types when necessary.
|
||||||
@@ -75,8 +76,11 @@ private class AutoboxingTransformer(val context: Context) : AbstractValueUsageTr
|
|||||||
IrTypeOperator.CAST, IrTypeOperator.IMPLICIT_CAST,
|
IrTypeOperator.CAST, IrTypeOperator.IMPLICIT_CAST,
|
||||||
IrTypeOperator.IMPLICIT_NOTNULL, IrTypeOperator.SAFE_CAST -> {
|
IrTypeOperator.IMPLICIT_NOTNULL, IrTypeOperator.SAFE_CAST -> {
|
||||||
|
|
||||||
// Codegen produces the object reference:
|
val newExpressionType = if (expression.operator == IrTypeOperator.SAFE_CAST) {
|
||||||
val newExpressionType = builtIns.nullableAnyType
|
newTypeOperand.makeNullable()
|
||||||
|
} else {
|
||||||
|
newTypeOperand
|
||||||
|
}
|
||||||
|
|
||||||
IrTypeOperatorCallImpl(expression.startOffset, expression.endOffset,
|
IrTypeOperatorCallImpl(expression.startOffset, expression.endOffset,
|
||||||
newExpressionType, expression.operator, newTypeOperand,
|
newExpressionType, expression.operator, newTypeOperand,
|
||||||
|
|||||||
Reference in New Issue
Block a user