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 7c39dec5b90..65f29347105 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 @@ -105,7 +105,7 @@ class IrInterpreter(irModule: IrModuleFragment) { else -> TODO("${this.javaClass} not supported") } - return executionResult.getNextLabel(this, data) { runBlocking { this@getNextLabel.interpret(it) } } + return executionResult.getNextLabel(this, data) { this@getNextLabel.interpret(it) } } catch (e: Throwable) { // catch exception from JVM such as: ArithmeticException, StackOverflowError and others val exceptionName = e::class.java.simpleName diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/interpreter/Label.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/interpreter/Label.kt index 59ca298b124..f09b790b883 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/interpreter/Label.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/interpreter/Label.kt @@ -20,7 +20,7 @@ enum class ReturnLabel { interface ExecutionResult { val returnLabel: ReturnLabel - fun getNextLabel(irElement: IrElement, data: Frame, interpret: IrElement.(Frame) -> ExecutionResult): ExecutionResult + suspend fun getNextLabel(irElement: IrElement, data: Frame, interpret: suspend IrElement.(Frame) -> ExecutionResult): ExecutionResult } inline fun ExecutionResult.check(toCheckLabel: ReturnLabel = ReturnLabel.NEXT, returnBlock: (ExecutionResult) -> Unit): ExecutionResult { @@ -38,8 +38,10 @@ inline fun ExecutionResult.checkForReturn(newFrame: Frame, oldFrame: Frame, retu return this } -open class ExecutionResultWithoutInfo(override val returnLabel: ReturnLabel): ExecutionResult { - override fun getNextLabel(irElement: IrElement, data: Frame, interpret: IrElement.(Frame) -> ExecutionResult): ExecutionResult { +open class ExecutionResultWithoutInfo(override val returnLabel: ReturnLabel) : ExecutionResult { + override suspend fun getNextLabel( + irElement: IrElement, data: Frame, interpret: suspend IrElement.(Frame) -> ExecutionResult + ): ExecutionResult { return when (returnLabel) { ReturnLabel.RETURN -> this ReturnLabel.BREAK_WHEN -> when (irElement) { @@ -58,8 +60,10 @@ open class ExecutionResultWithoutInfo(override val returnLabel: ReturnLabel): Ex } } -class ExecutionResultWithInfo(override val returnLabel: ReturnLabel, val info: String): ExecutionResultWithoutInfo(returnLabel) { - override fun getNextLabel(irElement: IrElement, data: Frame, interpret: IrElement.(Frame) -> ExecutionResult): ExecutionResult { +class ExecutionResultWithInfo(override val returnLabel: ReturnLabel, val info: String) : ExecutionResultWithoutInfo(returnLabel) { + override suspend fun getNextLabel( + irElement: IrElement, data: Frame, interpret: suspend IrElement.(Frame) -> ExecutionResult + ): ExecutionResult { return when (returnLabel) { ReturnLabel.RETURN -> when (irElement) { is IrCall -> if (info == irElement.symbol.descriptor.toString()) Next else this