Mark linenumber in property reference

This commit is contained in:
Michael Bogdanov
2016-08-22 15:20:55 +03:00
parent b4ae70139a
commit 237afb4b7c
6 changed files with 70 additions and 2 deletions
@@ -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)
}
@@ -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
@@ -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
@@ -0,0 +1,14 @@
package functionReference
fun test(s: () -> String) {
s()
}
fun a() = "OK"
fun main(args: Array<String>) {
//Breakpoint!
test(::a)
}
// NB: stepping is not clear
// STEP_INTO: 7
@@ -0,0 +1,14 @@
package propertyReference
fun test(s: () -> String) {
s()
}
val a: String get() = "OK"
fun main(args: Array<String>) {
//Breakpoint!
test(::a)
}
// NB: stepping is not clear
// STEP_INTO: 7
@@ -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");