diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/extractFunctionForDebuggerUtil.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/extractFunctionForDebuggerUtil.kt index 1ba8a1d97c2..3ed7e28b939 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/extractFunctionForDebuggerUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/extractFunctionForDebuggerUtil.kt @@ -185,7 +185,19 @@ private fun addDebugExpressionBeforeContextElement(codeFragment: JetCodeFragment val elementBefore = when { contextElement is JetProperty && !contextElement.isLocal() -> { - wrapInRunFun(contextElement.getDelegateExpressionOrInitializer()!!) + val delegateExpressionOrInitializer = contextElement.getDelegateExpressionOrInitializer() + if (delegateExpressionOrInitializer != null) { + wrapInRunFun(delegateExpressionOrInitializer) + } + else { + val getter = contextElement.getGetter()!! + if (!getter.hasBlockBody()) { + wrapInRunFun(getter.getBodyExpression()!!) + } + else { + (getter.getBodyExpression() as JetBlockExpression).getStatements().first() + } + } } contextElement is JetClassOrObject -> { insertNewInitializer(contextElement.getBody()) diff --git a/idea/testData/debugger/tinyApp/outs/withoutBodyProperties.out b/idea/testData/debugger/tinyApp/outs/withoutBodyProperties.out index 23229406ada..a5283e2b7cc 100644 --- a/idea/testData/debugger/tinyApp/outs/withoutBodyProperties.out +++ b/idea/testData/debugger/tinyApp/outs/withoutBodyProperties.out @@ -1,8 +1,10 @@ LineBreakpoint created at withoutBodyProperties.kt:8 LineBreakpoint created at withoutBodyProperties.kt:13 LineBreakpoint created at withoutBodyProperties.kt:18 -LineBreakpoint created at withoutBodyProperties.kt:29 -LineBreakpoint created at withoutBodyProperties.kt:36 +LineBreakpoint created at withoutBodyProperties.kt:23 +LineBreakpoint created at withoutBodyProperties.kt:28 +LineBreakpoint created at withoutBodyProperties.kt:39 +LineBreakpoint created at withoutBodyProperties.kt:46 !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! withoutBodyProperties.WithoutBodyPropertiesPackage Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' withoutBodyProperties.kt:8 @@ -11,11 +13,15 @@ withoutBodyProperties.kt:13 Compile bytecode for 1 + 2 withoutBodyProperties.kt:18 Compile bytecode for 1 + 3 -withoutBodyProperties.kt:29 -Compile bytecode for i -withoutBodyProperties.kt:29 -withoutBodyProperties.kt:36 +withoutBodyProperties.kt:23 Compile bytecode for 1 + 4 +withoutBodyProperties.kt:28 +Compile bytecode for 1 + 5 +withoutBodyProperties.kt:39 +Compile bytecode for i +withoutBodyProperties.kt:39 +withoutBodyProperties.kt:46 +Compile bytecode for 1 + 6 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/evaluate/multipleBreakpoints/withoutBodyProperties.kt b/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/withoutBodyProperties.kt index 28cfcfad581..4378fe56b2c 100644 --- a/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/withoutBodyProperties.kt +++ b/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/withoutBodyProperties.kt @@ -17,6 +17,16 @@ var aDelegate: Int by Delegates.notNull() //Breakpoint! val aLambda = { 1 + 1 } +// EXPRESSION: 1 + 4 +// RESULT: 5: I +//Breakpoint! +val aWoBody: Int get() = 1 + +// EXPRESSION: 1 + 5 +// RESULT: 6: I +//Breakpoint! +val aWoBody2: Int get() { return 1 } + class A { init { // EXPRESSION: i @@ -30,8 +40,8 @@ class A { } } - // EXPRESSION: 1 + 4 - // RESULT: 5: I + // EXPRESSION: 1 + 6 + // RESULT: 7: I //Breakpoint! val prop = 1 } @@ -40,6 +50,8 @@ fun main(args: Array) { a aDelegate = 1 aLambda + aWoBody + aWoBody2 A().prop } \ No newline at end of file