diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index d7320226dfb..a04022d1b33 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -4358,6 +4358,9 @@ The "returned" value of try expression with no finally is either the last expres int index = lookupLocalIndex(descriptor); v.store(index, descriptorType); + Label catchVariableStart = new Label(); + v.mark(catchVariableStart); + gen(catchBody, expectedAsmType); if (!isStatement) { @@ -4369,8 +4372,8 @@ The "returned" value of try expression with no finally is either the last expres Label clauseEnd = new Label(); v.mark(clauseEnd); - v.visitLocalVariable(descriptor.getName().asString(), descriptorType.getDescriptor(), null, clauseStart, clauseEnd, - index); + v.visitLocalVariable(descriptor.getName().asString(), descriptorType.getDescriptor(), null, + catchVariableStart, clauseEnd, index); genFinallyBlockOrGoto(finallyBlockStackElement, i != size - 1 || finallyBlock != null ? end : null, null); diff --git a/compiler/testData/checkLocalVariablesTable/catchClause.kt b/compiler/testData/checkLocalVariablesTable/catchClause.kt index 0ccbddc6be5..66901447d3e 100644 --- a/compiler/testData/checkLocalVariablesTable/catchClause.kt +++ b/compiler/testData/checkLocalVariablesTable/catchClause.kt @@ -5,7 +5,7 @@ class A { a++ } catch(e : Throwable) { - + e.printStackTrace() } } } diff --git a/idea/testData/debugger/tinyApp/outs/catchVariable.out b/idea/testData/debugger/tinyApp/outs/catchVariable.out new file mode 100644 index 00000000000..23465273f2e --- /dev/null +++ b/idea/testData/debugger/tinyApp/outs/catchVariable.out @@ -0,0 +1,23 @@ +LineBreakpoint created at catchVariable.kt:9 +!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !OUTPUT_PATH!;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! catchVariable.CatchVariableKt +Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' +catchVariable.kt:9 +package catchVariable + +fun main(args: Array) { + try { + throw Exception() + + } + //Breakpoint! + catch (e: Exception) { + + } +} + +// PRINT_FRAME + frame = main:9, CatchVariableKt {catchVariable} + local = args: java.lang.String[] = {java.lang.String[0]@uniqueID} (sp = catchVariable.kt, 3) +Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' + +Process finished with exit code 0 diff --git a/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/catchVariable.kt b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/catchVariable.kt new file mode 100644 index 00000000000..3bb4590a158 --- /dev/null +++ b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/catchVariable.kt @@ -0,0 +1,14 @@ +package catchVariable + +fun main(args: Array) { + try { + throw Exception() + + } + //Breakpoint! + catch (e: Exception) { + + } +} + +// PRINT_FRAME \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java index 7c27013c445..0c5055c4399 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java @@ -559,6 +559,12 @@ public class KotlinEvaluateExpressionTestGenerated extends AbstractKotlinEvaluat KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } + @TestMetadata("catchVariable.kt") + public void testCatchVariable() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/catchVariable.kt"); + doSingleBreakpointTest(fileName); + } + @TestMetadata("delegatedPropertyInClass.kt") public void testDelegatedPropertyInClass() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/delegatedPropertyInClass.kt");