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 98e05f189b5..343cdd76911 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 @@ -29,6 +29,7 @@ import org.jetbrains.kotlin.ir.types.impl.originalKotlinType import org.jetbrains.kotlin.ir.util.* import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult import java.lang.invoke.MethodHandle private const val MAX_COMMANDS = 500_000 @@ -206,6 +207,7 @@ class IrInterpreter(val irBuiltIns: IrBuiltIns, private val bodyMap: Map throw InterpreterError("Unsupported number of arguments for invocation as builtin functions") } } + // TODO check "result is Unit" stack.pushReturnValue(result.toState(result.getType(irFunction.returnType))) return Next } @@ -235,8 +237,15 @@ class IrInterpreter(val irBuiltIns: IrBuiltIns, private val bodyMap: Map listOf(result.value) is Primitive<*> -> when { - expression.varargElementType.isArray() -> listOf(result) + expression.varargElementType.isArray() || expression.varargElementType.isPrimitiveArray() -> listOf(result) else -> arrayToList(result.value) } is Common -> when { diff --git a/compiler/ir/ir.interpreter/src/org/jetbrains/kotlin/ir/interpreter/stack/Stack.kt b/compiler/ir/ir.interpreter/src/org/jetbrains/kotlin/ir/interpreter/stack/Stack.kt index f2dee0adc7e..53270fcd667 100644 --- a/compiler/ir/ir.interpreter/src/org/jetbrains/kotlin/ir/interpreter/stack/Stack.kt +++ b/compiler/ir/ir.interpreter/src/org/jetbrains/kotlin/ir/interpreter/stack/Stack.kt @@ -110,7 +110,7 @@ internal class StackImpl : Stack { override fun clean(rootFile: IrFile?) { stackCount = 0 frameList.clear() - rootFile?.let { frameList.add(FrameContainer(rootFile)) } + frameList.add(FrameContainer(rootFile)) } override fun addVar(variable: Variable) {