diff --git a/ChangeLog.md b/ChangeLog.md index 5b79ed2cb2b..8de30ead4ee 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -192,6 +192,7 @@ Issues fixed: - Avoid cast to runtime type unavailable in current scope - Fix text with line breaks in popup with line breakpoint variants - Fix breakpoints inside inline functions in libraries sources +- Allow breakpoints at catch clause declaration ### Java to Kotlin converter diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index f70375fa169..3c5481265ce 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -3667,6 +3667,11 @@ The "returned" value of try expression with no finally is either the last expres Label clauseStart = new Label(); v.mark(clauseStart); + KtExpression catchBody = clause.getCatchBody(); + if (catchBody != null) { + markLineNumber(catchBody, false); + } + VariableDescriptor descriptor = bindingContext.get(VALUE_PARAMETER, clause.getCatchParameter()); assert descriptor != null; Type descriptorType = asmType(descriptor.getType()); @@ -3674,7 +3679,7 @@ The "returned" value of try expression with no finally is either the last expres int index = lookupLocalIndex(descriptor); v.store(index, descriptorType); - gen(clause.getCatchBody(), expectedAsmType); + gen(catchBody, expectedAsmType); if (!isStatement) { v.store(savedValue, expectedAsmType); diff --git a/compiler/testData/lineNumber/custom/tryCatchExpression.kt b/compiler/testData/lineNumber/custom/tryCatchExpression.kt index d6a577c63ed..c1929e12c21 100644 --- a/compiler/testData/lineNumber/custom/tryCatchExpression.kt +++ b/compiler/testData/lineNumber/custom/tryCatchExpression.kt @@ -12,4 +12,4 @@ fun foo() { } } -// 2 3 5 6 8 9 11 8 13 +// 2 3 4 5 6 8 9 10 11 8 13 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/tryCatchFinally.kt b/compiler/testData/lineNumber/custom/tryCatchFinally.kt index 02158a669be..e418cae339f 100644 --- a/compiler/testData/lineNumber/custom/tryCatchFinally.kt +++ b/compiler/testData/lineNumber/custom/tryCatchFinally.kt @@ -16,4 +16,4 @@ fun foo() { } } -// 2 3 7 5 7 8 10 11 15 13 15 10 17 +// 2 3 7 4 5 7 8 10 11 15 12 13 15 10 17 \ No newline at end of file diff --git a/idea/testData/debugger/tinyApp/outs/stepOverCatchClause.out b/idea/testData/debugger/tinyApp/outs/stepOverCatchClause.out new file mode 100644 index 00000000000..97c523f5a8f --- /dev/null +++ b/idea/testData/debugger/tinyApp/outs/stepOverCatchClause.out @@ -0,0 +1,9 @@ +LineBreakpoint created at stepOverCatchClause.kt:14 +!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! stepOverCatchClause.StepOverCatchClauseKt +Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' +stepOverCatchClause.kt:14 +stepOverCatchClause.kt:7 +stepOverCatchClause.kt:8 +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/outs/stepOverTryCatchWithInline.out b/idea/testData/debugger/tinyApp/outs/stepOverTryCatchWithInline.out index f1fba0b98fb..099b953cdc8 100644 --- a/idea/testData/debugger/tinyApp/outs/stepOverTryCatchWithInline.out +++ b/idea/testData/debugger/tinyApp/outs/stepOverTryCatchWithInline.out @@ -8,11 +8,13 @@ stepOverTryCatchWithInline.kt:48 stepOverTryCatchWithInline.kt:17 stepOverTryCatchWithInline.kt:24 stepOverTryCatchWithInline.kt:25 +stepOverTryCatchWithInline.kt:27 stepOverTryCatchWithInline.kt:28 stepOverTryCatchWithInline.kt:35 stepOverTryCatchWithInline.kt:36 stepOverTryCatchWithInline.kt:48 stepOverTryCatchWithInline.kt:36 +stepOverTryCatchWithInline.kt:38 stepOverTryCatchWithInline.kt:39 stepOverTryCatchWithInline.kt:43 stepOverTryCatchWithInline.kt:8 diff --git a/idea/testData/debugger/tinyApp/src/stepping/stepOver/stepOverCatchClause.kt b/idea/testData/debugger/tinyApp/src/stepping/stepOver/stepOverCatchClause.kt new file mode 100644 index 00000000000..b5f029213d9 --- /dev/null +++ b/idea/testData/debugger/tinyApp/src/stepping/stepOver/stepOverCatchClause.kt @@ -0,0 +1,17 @@ +package stepOverCatchClause + +fun main(args: Array) { + try { + bar() + } + catch(e: Exception) { + val a = e + } +} + +fun bar() { + //Breakpoint! + throw IllegalStateException() +} + +// STEP_OVER: 2 \ No newline at end of file diff --git a/idea/testData/debugger/tinyApp/src/stepping/stepOver/stepOverTryCatchWithInline.kt b/idea/testData/debugger/tinyApp/src/stepping/stepOver/stepOverTryCatchWithInline.kt index f8571adf20f..d50444e5c79 100644 --- a/idea/testData/debugger/tinyApp/src/stepping/stepOver/stepOverTryCatchWithInline.kt +++ b/idea/testData/debugger/tinyApp/src/stepping/stepOver/stepOverTryCatchWithInline.kt @@ -51,4 +51,4 @@ inline fun foo(f: () -> Int): Int { fun test(i: Int) = 1 -// STEP_OVER: 15 \ No newline at end of file +// STEP_OVER: 19 \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinSteppingTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinSteppingTestGenerated.java index 2726ac6691e..5fe17cadd4f 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinSteppingTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinSteppingTestGenerated.java @@ -379,6 +379,12 @@ public class KotlinSteppingTestGenerated extends AbstractKotlinSteppingTest { doStepOverTest(fileName); } + @TestMetadata("stepOverCatchClause.kt") + public void testStepOverCatchClause() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepOver/stepOverCatchClause.kt"); + doStepOverTest(fileName); + } + @TestMetadata("stepOverForWithInline.kt") public void testStepOverForWithInline() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepOver/stepOverForWithInline.kt");