Experiment
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 ab1e0e3..590cd76 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
@@ -8,7 +8,6 @@
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
-import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
import org.jetbrains.kotlin.ir.declarations.IrField
import org.jetbrains.kotlin.ir.declarations.IrFunction
@@ -18,8 +17,8 @@
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 {
@@ -48,15 +47,11 @@
transformChildren(this@IrInterpreterConstGetterPreprocessor, data)
+ val fieldParent = field.parentAsClass
+ val getObject = IrGetObjectValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, fieldParent.defaultType, fieldParent.symbol)
when (this) {
- is IrCall -> {
- val declaringClass = this.symbol.owner.parent
- require(declaringClass is IrClass)
- this.dispatchReceiver =
- IrGetObjectValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, declaringClass.defaultType, declaringClass.symbol)
- }
- is IrGetField -> this.receiver =
- IrGetObjectValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, receiver.type, receiver.type.classOrFail)
+ is IrCall -> this.dispatchReceiver = getObject
+ is IrGetField -> this.receiver = getObject
}
return if (receiver.shouldDropConstReceiver()) {