diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/interpreter/IrInterpreter.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/interpreter/IrInterpreter.kt index ff8fbe9f3cb..01eedebc9aa 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/interpreter/IrInterpreter.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/interpreter/IrInterpreter.kt @@ -480,7 +480,10 @@ class IrInterpreter(irModule: IrModuleFragment) { private fun interpretTypeOperatorCall(expression: IrTypeOperatorCall, data: Frame): Code { return when (expression.operator) { - IrTypeOperator.IMPLICIT_COERCION_TO_UNIT -> expression.argument.interpret(data) + IrTypeOperator.IMPLICIT_COERCION_TO_UNIT -> { + // coercion to unit means that return value isn't used + expression.argument.interpret(data).apply { if (this == Code.NEXT) data.popReturnValue() } + } IrTypeOperator.CAST, IrTypeOperator.IMPLICIT_CAST -> { val code = expression.argument.interpret(data) if (!data.peekReturnValue().irClass.defaultType.isSubtypeOf(expression.type, irBuiltIns)) { diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/interpreter/stack/State.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/interpreter/stack/State.kt index e0b40568904..909a930392b 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/interpreter/stack/State.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/interpreter/stack/State.kt @@ -35,7 +35,16 @@ interface State { } fun setState(newVar: Variable) + + /** + * This method is used for passing a copy of a state. + * It is necessary then copy change its state's value, but the original one must remain the same. + * + * @see copyReceivedValue.kt + * @see tryFinally.kt + */ fun copy(): State + fun getIrFunction(descriptor: FunctionDescriptor): IrFunction? }