From 15808cb37638f499640c94f70b8986059cd49785 Mon Sep 17 00:00:00 2001 From: Ivan Kylchik Date: Mon, 7 Jun 2021 23:25:40 +0300 Subject: [PATCH] Lower priority of captured variables in interpreter --- .../kotlin/ir/interpreter/IrInterpreter.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/compiler/ir/ir.interpreter/src/org/jetbrains/kotlin/ir/interpreter/IrInterpreter.kt b/compiler/ir/ir.interpreter/src/org/jetbrains/kotlin/ir/interpreter/IrInterpreter.kt index 576db190e55..a35bc6829dd 100644 --- a/compiler/ir/ir.interpreter/src/org/jetbrains/kotlin/ir/interpreter/IrInterpreter.kt +++ b/compiler/ir/ir.interpreter/src/org/jetbrains/kotlin/ir/interpreter/IrInterpreter.kt @@ -203,16 +203,16 @@ class IrInterpreter private constructor( irFunction.typeParameters.filter { it.isReified } .forEach { callStack.addVariable(Variable(it.symbol, KTypeState(call.getTypeArgument(it.index)!!, irBuiltIns.anyClass.owner))) } - // 5. load up values onto stack - if (irFunction.isLocal) callStack.copyUpValuesFromPreviousFrame() - if (dispatchReceiver is StateWithClosure) callStack.loadUpValues(dispatchReceiver) - if (extensionReceiver is StateWithClosure) callStack.loadUpValues(extensionReceiver) - - // 6. load outer class object + // 5. load outer class object if (dispatchReceiver is Complex && irFunction.parentClassOrNull?.isInner == true) { generateSequence(dispatchReceiver.outerClass) { (it.state as? Complex)?.outerClass }.forEach { callStack.addVariable(it) } } + // 6. load up values onto stack + if (irFunction.isLocal) callStack.copyUpValuesFromPreviousFrame() + if (dispatchReceiver is StateWithClosure) callStack.loadUpValues(dispatchReceiver) + if (extensionReceiver is StateWithClosure) callStack.loadUpValues(extensionReceiver) + callInterceptor.interceptCall(call, irFunction, args) { callStack.addInstruction(CompoundInstruction(irFunction)) } @@ -257,7 +257,6 @@ class IrInterpreter private constructor( callStack.addInstruction(SimpleInstruction(constructor)) callStack.addVariable(Variable(constructorCall.getThisReceiver(), objectState)) constructor.valueParameters.forEachIndexed { i, param -> callStack.addVariable(Variable(param.symbol, valueArguments[i])) } - if (irClass.isLocal) callStack.loadUpValues(objectState as StateWithClosure) val superReceiver = when (val irStatement = constructor.body?.statements?.get(0)) { null -> null // for jvm @@ -280,6 +279,7 @@ class IrInterpreter private constructor( // used to get information from outer class generateSequence(outerClassVar) { (it.state as? Complex)?.outerClass }.forEach { callStack.addVariable(it) } } + if (irClass.isLocal) callStack.loadUpValues(objectState as StateWithClosure) callInterceptor.interceptConstructor(constructorCall, valueArguments) { callStack.addInstruction(CompoundInstruction(constructor))