From 286196e8b2949ba84a847679292dc2fd661e4fd0 Mon Sep 17 00:00:00 2001 From: "vladislav.grechko" Date: Thu, 9 Nov 2023 16:38:18 +0100 Subject: [PATCH] Do not use receiver type as GET_OBJECT type when interpreting constants It is incompatible with type erasure of non-reified type parameters on inlining (which will be done in future). See NaNPropagationTest.kt for example. --- .../preprocessor/IrInterpreterConstGetterPreprocessor.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/ir/ir.interpreter/src/org/jetbrains/kotlin/ir/interpreter/preprocessor/IrInterpreterConstGetterPreprocessor.kt b/compiler/ir/ir.interpreter/src/org/jetbrains/kotlin/ir/interpreter/preprocessor/IrInterpreterConstGetterPreprocessor.kt index b14b208ac08..590cd768974 100644 --- a/compiler/ir/ir.interpreter/src/org/jetbrains/kotlin/ir/interpreter/preprocessor/IrInterpreterConstGetterPreprocessor.kt +++ b/compiler/ir/ir.interpreter/src/org/jetbrains/kotlin/ir/interpreter/preprocessor/IrInterpreterConstGetterPreprocessor.kt @@ -17,7 +17,8 @@ import org.jetbrains.kotlin.ir.expressions.impl.IrGetObjectValueImpl import org.jetbrains.kotlin.ir.interpreter.correspondingProperty import org.jetbrains.kotlin.ir.interpreter.isConst import org.jetbrains.kotlin.ir.interpreter.property -import org.jetbrains.kotlin.ir.types.classOrFail +import org.jetbrains.kotlin.ir.util.defaultType +import org.jetbrains.kotlin.ir.util.parentAsClass class IrInterpreterConstGetterPreprocessor : IrInterpreterPreprocessor { override fun visitFunction(declaration: IrFunction, data: IrInterpreterPreprocessorData): IrStatement { @@ -46,7 +47,8 @@ class IrInterpreterConstGetterPreprocessor : IrInterpreterPreprocessor { transformChildren(this@IrInterpreterConstGetterPreprocessor, data) - val getObject = IrGetObjectValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, receiver.type, receiver.type.classOrFail) + val fieldParent = field.parentAsClass + val getObject = IrGetObjectValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, fieldParent.defaultType, fieldParent.symbol) when (this) { is IrCall -> this.dispatchReceiver = getObject is IrGetField -> this.receiver = getObject