diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt index fe289407c75..5e3d4976000 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt @@ -519,7 +519,7 @@ class ExpressionCodegen( override fun visitSetVariable(expression: IrSetVariable, data: BlockInfo): PromisedValue { expression.markLineNumber(startOffset = true) setVariable(expression.symbol, expression.value, data) - return defaultValue(expression.type) + return immaterialUnitValue } fun setVariable(symbol: IrValueSymbol, value: IrExpression, data: BlockInfo) { @@ -751,7 +751,7 @@ class ExpressionCodegen( mv.nop() val tryAsmType = aTry.asmType val tryResult = aTry.tryResult.accept(this, data) - val isExpression = true //TODO: more wise check is required + val isExpression = !aTry.type.isUnit() var savedValue: Int? = null if (isExpression) { tryResult.coerce(tryAsmType, aTry.type).materialize() diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/FunctionCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/FunctionCodegen.kt index 7f9841a5ba5..4b56a822a71 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/FunctionCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/FunctionCodegen.kt @@ -6,7 +6,6 @@ package org.jetbrains.kotlin.backend.jvm.codegen import org.jetbrains.kotlin.backend.jvm.JvmBackendContext -import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin import org.jetbrains.kotlin.codegen.AsmUtil import org.jetbrains.kotlin.codegen.ClassBuilderMode import org.jetbrains.kotlin.codegen.visitAnnotableParameterCount diff --git a/compiler/testData/codegen/bytecodeText/coroutines/varValueConflictsWithTableSameSort.kt b/compiler/testData/codegen/bytecodeText/coroutines/varValueConflictsWithTableSameSort.kt index 5b469fc5624..260a1892833 100644 --- a/compiler/testData/codegen/bytecodeText/coroutines/varValueConflictsWithTableSameSort.kt +++ b/compiler/testData/codegen/bytecodeText/coroutines/varValueConflictsWithTableSameSort.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND: JVM_IR // WITH_COROUTINES import helpers.* @@ -41,6 +42,9 @@ fun box(): String { // 1 LOCALVARIABLE i Ljava/lang/String; L.* 3 // 1 LOCALVARIABLE s Ljava/lang/String; L.* 3 // 1 PUTFIELD VarValueConflictsWithTableSameSortKt\$box\$1.L\$0 : Ljava/lang/Object; -/* 1 load in try/finally */ +/* 1 load in the catch (e: Throwable) { throw e } block which is implicitly wrapped around try/finally */ +// 1 ALOAD 3\s+ATHROW /* 1 load in result = s */ +// 1 ALOAD 3\s+PUTFIELD kotlin/jvm/internal/Ref\$ObjectRef\.element +/* But no further load when spilling 's' to the continuation */ // 2 ALOAD 3 diff --git a/compiler/testData/codegen/bytecodeText/statements/tryCatchFinally.kt b/compiler/testData/codegen/bytecodeText/statements/tryCatchFinally.kt index 38e80522bbf..31145f208fe 100644 --- a/compiler/testData/codegen/bytecodeText/statements/tryCatchFinally.kt +++ b/compiler/testData/codegen/bytecodeText/statements/tryCatchFinally.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JVM_IR fun z() {} fun foo() {