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.
This commit is contained in:
vladislav.grechko
2023-11-09 16:38:18 +01:00
committed by Space Team
parent 44caa3cdd5
commit 286196e8b2
@@ -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