diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index d77662899cd..f84ecc20bab 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -661,6 +661,8 @@ public class ExpressionCodegen extends JetVisitor implem } public void afterBody(@NotNull Label loopExit) { + markLineNumber(forExpression); + increment(loopExit); v.mark(bodyEnd); diff --git a/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt index 27f4087775b..bb3d94dde6e 100644 --- a/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt +++ b/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt @@ -591,6 +591,7 @@ fun main(args: Array) { testClass(javaClass()) { model("debugger/tinyApp/src/stepInto/stepIntoAndSmartStepInto", testMethod = "doStepIntoTest", testClassName = "StepInto") model("debugger/tinyApp/src/stepInto/stepIntoAndSmartStepInto", testMethod = "doSmartStepIntoTest", testClassName = "SmartStepInto") + model("debugger/tinyApp/src/stepInto/stepInto", testMethod = "doStepIntoTest", testClassName = "StepIntoOnly") model("debugger/tinyApp/src/filters", testMethod = "doStepIntoTest") } diff --git a/idea/testData/debugger/tinyApp/outs/allFilesPresentInStepIntoOnly.out b/idea/testData/debugger/tinyApp/outs/allFilesPresentInStepIntoOnly.out new file mode 100644 index 00000000000..e69de29bb2d diff --git a/idea/testData/debugger/tinyApp/outs/continueLabel.out b/idea/testData/debugger/tinyApp/outs/continueLabel.out new file mode 100644 index 00000000000..eb1cf7788e0 --- /dev/null +++ b/idea/testData/debugger/tinyApp/outs/continueLabel.out @@ -0,0 +1,16 @@ +LineBreakpoint created at continueLabel.kt:5 +!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !APP_PATH!\classes;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! continueLabel.ContinueLabelPackage +Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' +continueLabel.kt:5 +continueLabel.kt:6 +continueLabel.kt:7 +continueLabel.kt:8 +continueLabel.kt:5 +continueLabel.kt:6 +continueLabel.kt:7 +continueLabel.kt:10 +continueLabel.kt:5 +continueLabel.kt:12 +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/forLoop.out b/idea/testData/debugger/tinyApp/outs/forLoop.out new file mode 100644 index 00000000000..a2442b1bca9 --- /dev/null +++ b/idea/testData/debugger/tinyApp/outs/forLoop.out @@ -0,0 +1,21 @@ +LineBreakpoint created at forLoop.kt:6 +!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !APP_PATH!\classes;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! forLoop.ForLoopPackage +Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' +forLoop.kt:6 +forLoop.kt:7 +forLoop.kt:8 +forLoop.kt:7 +forLoop.kt:8 +forLoop.kt:7 +forLoop.kt:10 +forLoop.kt:11 +forLoop.kt:12 +forLoop.kt:13 +forLoop.kt:11 +forLoop.kt:12 +forLoop.kt:13 +forLoop.kt:11 +forLoop.kt:15 +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/stepInto/stepInto/continueLabel.kt b/idea/testData/debugger/tinyApp/src/stepInto/stepInto/continueLabel.kt new file mode 100644 index 00000000000..872d1d87228 --- /dev/null +++ b/idea/testData/debugger/tinyApp/src/stepInto/stepInto/continueLabel.kt @@ -0,0 +1,15 @@ +package continueLabel + +fun main(args: Array) { + //Breakpoint! + for(el in 0..1) { + val a1 = 1 + if (el == 0) { + continue + } + val a2 = 2 + } + val a3 = 3 +} + +// STEP_INTO: 9 \ No newline at end of file diff --git a/idea/testData/debugger/tinyApp/src/stepInto/stepInto/forLoop.kt b/idea/testData/debugger/tinyApp/src/stepInto/stepInto/forLoop.kt new file mode 100644 index 00000000000..87325c8107c --- /dev/null +++ b/idea/testData/debugger/tinyApp/src/stepInto/stepInto/forLoop.kt @@ -0,0 +1,18 @@ +package forLoop + +// KT-5664 Wrong stepping through for loop +fun main(args: Array) { + //Breakpoint! + var x = 1 + for (i in 0..1) { + x++ + } + var y = 1 + for (i in 0..1) { + y++ + val y1 = y + } + val z = 1 +} + +// STEP_INTO: 14 \ No newline at end of file diff --git a/idea/tests/org/jetbrains/jet/plugin/debugger/KotlinSteppingTestGenerated.java b/idea/tests/org/jetbrains/jet/plugin/debugger/KotlinSteppingTestGenerated.java index 28a184966a2..810878d2d78 100644 --- a/idea/tests/org/jetbrains/jet/plugin/debugger/KotlinSteppingTestGenerated.java +++ b/idea/tests/org/jetbrains/jet/plugin/debugger/KotlinSteppingTestGenerated.java @@ -28,7 +28,7 @@ import java.util.regex.Pattern; /** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ @SuppressWarnings("all") -@InnerTestClasses({KotlinSteppingTestGenerated.StepInto.class, KotlinSteppingTestGenerated.SmartStepInto.class, KotlinSteppingTestGenerated.Filters.class}) +@InnerTestClasses({KotlinSteppingTestGenerated.StepInto.class, KotlinSteppingTestGenerated.SmartStepInto.class, KotlinSteppingTestGenerated.StepIntoOnly.class, KotlinSteppingTestGenerated.Filters.class}) @RunWith(JUnit3RunnerWithInners.class) public class KotlinSteppingTestGenerated extends AbstractKotlinSteppingTest { @TestMetadata("idea/testData/debugger/tinyApp/src/stepInto/stepIntoAndSmartStepInto") @@ -205,6 +205,27 @@ public class KotlinSteppingTestGenerated extends AbstractKotlinSteppingTest { } } + @TestMetadata("idea/testData/debugger/tinyApp/src/stepInto/stepInto") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class StepIntoOnly extends AbstractKotlinSteppingTest { + public void testAllFilesPresentInStepIntoOnly() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/debugger/tinyApp/src/stepInto/stepInto"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("continueLabel.kt") + public void testContinueLabel() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepInto/stepInto/continueLabel.kt"); + doStepIntoTest(fileName); + } + + @TestMetadata("forLoop.kt") + public void testForLoop() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepInto/stepInto/forLoop.kt"); + doStepIntoTest(fileName); + } + } + @TestMetadata("idea/testData/debugger/tinyApp/src/filters") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)