From 02722e02386e005f304cc44b26a2406093ba273c Mon Sep 17 00:00:00 2001 From: pyos Date: Wed, 15 Jan 2020 10:15:56 +0100 Subject: [PATCH] JVM_IR: mark the exception local as live only after the store Otherwise, should the local coincide with another one, the incorrect range causes D8 to generate invalid bytecode in debug mode. --- .../kotlin/backend/jvm/codegen/ExpressionCodegen.kt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) 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 8bd18bef580..daf4cb788a9 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 @@ -824,6 +824,7 @@ class ExpressionCodegen( val index = frameMap.enter(clause.catchParameter, descriptorType) clause.markLineNumber(true) mv.store(index, descriptorType) + val afterStore = markNewLabel() val catchBody = clause.result val catchResult = catchBody.accept(this, data) @@ -837,11 +838,7 @@ class ExpressionCodegen( frameMap.leave(clause.catchParameter) val clauseEnd = markNewLabel() - - mv.visitLocalVariable( - parameter.name.asString(), descriptorType.descriptor, null, clauseStart, clauseEnd, - index - ) + mv.visitLocalVariable(parameter.name.asString(), descriptorType.descriptor, null, afterStore, clauseEnd, index) if (tryInfo is TryWithFinallyInfo) { data.handleBlock { genFinallyBlock(tryInfo, tryCatchBlockEnd, null, data) }