From 4a2e4312eafd774072605464d44ddd6478fe33ff Mon Sep 17 00:00:00 2001 From: Natalia Ukhorskaya Date: Tue, 24 Nov 2015 10:23:25 +0300 Subject: [PATCH] Write lineNumber when inline function result is written to property --- .../kotlin/codegen/ExpressionCodegen.java | 7 ++- .../lineNumber/custom/compileTimeConstant.kt | 2 +- .../outs/functionCallStoredToVariable.out | 21 ++++++++ .../custom/functionCallStoredToVariable.kt | 48 +++++++++++++++++++ .../debugger/KotlinSteppingTestGenerated.java | 6 +++ 5 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 idea/testData/debugger/tinyApp/outs/functionCallStoredToVariable.out create mode 100644 idea/testData/debugger/tinyApp/src/stepping/custom/functionCallStoredToVariable.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index 19fe3036eb8..f39dde393db 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -3323,7 +3323,12 @@ public class ExpressionCodegen extends KtVisitor impleme StackValue storeTo = sharedVarType == null ? StackValue.local(index, varType) : StackValue.shared(index, varType); - storeTo.store(initializer, v); + storeTo.putReceiver(v, false); + initializer.put(initializer.type, v); + + markLineNumber(variableDeclaration, false); + + storeTo.storeSelector(initializer.type, v); } @NotNull diff --git a/compiler/testData/lineNumber/custom/compileTimeConstant.kt b/compiler/testData/lineNumber/custom/compileTimeConstant.kt index 47a285b40cb..ef023d32f0c 100644 --- a/compiler/testData/lineNumber/custom/compileTimeConstant.kt +++ b/compiler/testData/lineNumber/custom/compileTimeConstant.kt @@ -3,4 +3,4 @@ fun foo() { 42 } -// 2 3 4 +// 2 3 2 4 diff --git a/idea/testData/debugger/tinyApp/outs/functionCallStoredToVariable.out b/idea/testData/debugger/tinyApp/outs/functionCallStoredToVariable.out new file mode 100644 index 00000000000..cf4fc12a5fd --- /dev/null +++ b/idea/testData/debugger/tinyApp/outs/functionCallStoredToVariable.out @@ -0,0 +1,21 @@ +LineBreakpoint created at functionCallStoredToVariable.kt:7 +LineBreakpoint created at functionCallStoredToVariable.kt:14 +LineBreakpoint created at functionCallStoredToVariable.kt:21 +LineBreakpoint created at functionCallStoredToVariable.kt:28 +!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! functionCallStoredToVariable.FunctionCallStoredToVariableKt +Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' +functionCallStoredToVariable.kt:7 +functionCallStoredToVariable.kt:4 +functionCallStoredToVariable.kt:14 +functionCallStoredToVariable.kt:0 +functionCallStoredToVariable.kt:43 +functionCallStoredToVariable.kt:11 +functionCallStoredToVariable.kt:21 +functionCallStoredToVariable.kt:18 +functionCallStoredToVariable.kt:28 +functionCallStoredToVariable.kt:0 +functionCallStoredToVariable.kt:47 +functionCallStoredToVariable.kt:25 +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/stepping/custom/functionCallStoredToVariable.kt b/idea/testData/debugger/tinyApp/src/stepping/custom/functionCallStoredToVariable.kt new file mode 100644 index 00000000000..510e3d07bc5 --- /dev/null +++ b/idea/testData/debugger/tinyApp/src/stepping/custom/functionCallStoredToVariable.kt @@ -0,0 +1,48 @@ +package functionCallStoredToVariable + +fun main(args: Array) { + val a = inlineFunInt { + // STEP_OVER: 1 + //Breakpoint! + 1 + } + + // RESUME: 1 + val b = simpleFunInt { + // STEP_OVER: 3 + //Breakpoint! + 1 + } + + // RESUME: 1 + val c = inlineFunVoid { + // STEP_OVER: 1 + //Breakpoint! + val aa = 1 + } + + // RESUME: 1 + val d = simpleFunVoid { + // STEP_OVER: 3 + //Breakpoint! + val aa = 1 + } +} + +inline fun inlineFunInt(f: () -> Int): Int { + val a = 1 + return f() +} + +inline fun inlineFunVoid(f: () -> Unit): Unit { + val a = 1 + return f() +} + +fun simpleFunInt(f: () -> Int): Int { + return f() +} + +fun simpleFunVoid(f: () -> Unit): Unit { + return f() +} \ 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 2ccc17312a7..7be712720a7 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinSteppingTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinSteppingTestGenerated.java @@ -511,6 +511,12 @@ public class KotlinSteppingTestGenerated extends AbstractKotlinSteppingTest { doCustomTest(fileName); } + @TestMetadata("functionCallStoredToVariable.kt") + public void testFunctionCallStoredToVariable() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/custom/functionCallStoredToVariable.kt"); + doCustomTest(fileName); + } + @TestMetadata("fwAbstractProperty.kt") public void testFwAbstractProperty() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/custom/fwAbstractProperty.kt");