From 237afb4b7ceef4d86cef1d6d12d22117ce0e0bcd Mon Sep 17 00:00:00 2001 From: Michael Bogdanov Date: Mon, 22 Aug 2016 15:20:55 +0300 Subject: [PATCH] Mark linenumber in property reference --- .../kotlin/codegen/PropertyReferenceCodegen.kt | 6 ++++-- .../debugger/tinyApp/outs/functionReference.out | 13 +++++++++++++ .../debugger/tinyApp/outs/propertyReference.out | 13 +++++++++++++ .../src/stepping/stepInto/functionReference.kt | 14 ++++++++++++++ .../src/stepping/stepInto/propertyReference.kt | 14 ++++++++++++++ .../idea/debugger/KotlinSteppingTestGenerated.java | 12 ++++++++++++ 6 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 idea/testData/debugger/tinyApp/outs/functionReference.out create mode 100644 idea/testData/debugger/tinyApp/outs/propertyReference.out create mode 100644 idea/testData/debugger/tinyApp/src/stepping/stepInto/functionReference.kt create mode 100644 idea/testData/debugger/tinyApp/src/stepping/stepInto/propertyReference.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyReferenceCodegen.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyReferenceCodegen.kt index 9b83cda0673..9a95ad6a849 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyReferenceCodegen.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyReferenceCodegen.kt @@ -136,12 +136,12 @@ class PropertyReferenceCodegen( private fun generateAccessors() { val getFunction = findGetFunction(localVariableDescriptorForReference) val getImpl = createFakeOpenDescriptor(getFunction, classDescriptor) - functionCodegen.generateMethod(JvmDeclarationOrigin.NO_ORIGIN, getImpl, PropertyReferenceGenerationStrategy(true, getFunction, target, asmType, receiverType, state)) + functionCodegen.generateMethod(JvmDeclarationOrigin.NO_ORIGIN, getImpl, PropertyReferenceGenerationStrategy(true, getFunction, target, asmType, receiverType, element, state)) if (!ReflectionTypes.isNumberedKMutablePropertyType(localVariableDescriptorForReference.type)) return val setFunction = localVariableDescriptorForReference.type.memberScope.getContributedFunctions(OperatorNameConventions.SET, NoLookupLocation.FROM_BACKEND).single() val setImpl = createFakeOpenDescriptor(setFunction, classDescriptor) - functionCodegen.generateMethod(JvmDeclarationOrigin.NO_ORIGIN, setImpl, PropertyReferenceGenerationStrategy(false, setFunction, target, asmType, receiverType, state)) + functionCodegen.generateMethod(JvmDeclarationOrigin.NO_ORIGIN, setImpl, PropertyReferenceGenerationStrategy(false, setFunction, target, asmType, receiverType, element, state)) } @@ -223,6 +223,7 @@ class PropertyReferenceCodegen( val target: VariableDescriptor, val asmType: Type, val receiverType: Type?, + val expression: KtElement, state: GenerationState ) : FunctionGenerationStrategy.CodegenBased(state) { @@ -251,6 +252,7 @@ class PropertyReferenceCodegen( else codegen.intermediateValueForProperty(target as PropertyDescriptor, false, null, StackValue.none()) + codegen.markStartLineNumber(expression) if (isGetter) { value.put(OBJECT_TYPE, v) } diff --git a/idea/testData/debugger/tinyApp/outs/functionReference.out b/idea/testData/debugger/tinyApp/outs/functionReference.out new file mode 100644 index 00000000000..5f7c515c331 --- /dev/null +++ b/idea/testData/debugger/tinyApp/outs/functionReference.out @@ -0,0 +1,13 @@ +LineBreakpoint created at functionReference.kt:11 +!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! functionReference.FunctionReferenceKt +Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' +functionReference.kt:11 +functionReference.kt:4 +functionReference.kt:7 +functionReference.kt:11 +functionReference.kt:4 +functionReference.kt:5 +functionReference.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/propertyReference.out b/idea/testData/debugger/tinyApp/outs/propertyReference.out new file mode 100644 index 00000000000..52e401c842d --- /dev/null +++ b/idea/testData/debugger/tinyApp/outs/propertyReference.out @@ -0,0 +1,13 @@ +LineBreakpoint created at propertyReference.kt:11 +!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! propertyReference.PropertyReferenceKt +Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' +propertyReference.kt:11 +propertyReference.kt:4 +propertyReference.kt:7 +propertyReference.kt:11 +propertyReference.kt:4 +propertyReference.kt:5 +propertyReference.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/src/stepping/stepInto/functionReference.kt b/idea/testData/debugger/tinyApp/src/stepping/stepInto/functionReference.kt new file mode 100644 index 00000000000..196293adf9a --- /dev/null +++ b/idea/testData/debugger/tinyApp/src/stepping/stepInto/functionReference.kt @@ -0,0 +1,14 @@ +package functionReference + +fun test(s: () -> String) { + s() +} + +fun a() = "OK" + +fun main(args: Array) { + //Breakpoint! + test(::a) +} +// NB: stepping is not clear +// STEP_INTO: 7 \ No newline at end of file diff --git a/idea/testData/debugger/tinyApp/src/stepping/stepInto/propertyReference.kt b/idea/testData/debugger/tinyApp/src/stepping/stepInto/propertyReference.kt new file mode 100644 index 00000000000..f27ddf5b757 --- /dev/null +++ b/idea/testData/debugger/tinyApp/src/stepping/stepInto/propertyReference.kt @@ -0,0 +1,14 @@ +package propertyReference + +fun test(s: () -> String) { + s() +} + +val a: String get() = "OK" + +fun main(args: Array) { + //Breakpoint! + test(::a) +} +// NB: stepping is not clear +// STEP_INTO: 7 \ 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 f64fdaa7fce..fbfb4fba1a1 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinSteppingTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinSteppingTestGenerated.java @@ -241,12 +241,24 @@ public class KotlinSteppingTestGenerated extends AbstractKotlinSteppingTest { doStepIntoTest(fileName); } + @TestMetadata("functionReference.kt") + public void testFunctionReference() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepInto/functionReference.kt"); + doStepIntoTest(fileName); + } + @TestMetadata("inlineOnly.kt") public void testInlineOnly() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepInto/inlineOnly.kt"); doStepIntoTest(fileName); } + @TestMetadata("propertyReference.kt") + public void testPropertyReference() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepInto/propertyReference.kt"); + doStepIntoTest(fileName); + } + @TestMetadata("returnVoid.kt") public void testReturnVoid() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepInto/returnVoid.kt");