Debugger doesn't step into 'for' body if there's inline function call in range expression (KT-13534)

#KT-13534 Fixed
This commit is contained in:
Nikolay Krasko
2016-08-24 16:26:22 +03:00
committed by Nikolay Krasko
parent ef602be98e
commit 8b84b7158a
7 changed files with 84 additions and 3 deletions
@@ -105,7 +105,7 @@ public class DebuggerSteppingHelper {
try {
StackFrameProxyImpl frameProxy = suspendContext.getFrameProxy();
if (frameProxy != null) {
Action action = KotlinSteppingCommandProviderKt.getStepOutPosition(
Action action = KotlinSteppingCommandProviderKt.getStepOutAction(
frameProxy.location(),
suspendContext,
inlineFunctions,
@@ -347,10 +347,25 @@ fun getStepOverPosition(
}
}
fun isBackEdgeLocation(): Boolean {
val previousSuitableLocation = computedReferenceType.allLineLocations().reversed()
.dropWhile { it != location }
.drop(1)
.filter(::isLocationSuitable)
.dropWhile { it.lineNumber() == location.lineNumber() }
.firstOrNull()
return previousSuitableLocation != null && previousSuitableLocation.lineNumber() > location.lineNumber()
}
if (isBackEdgeLocation()) {
return Action.STEP_OVER()
}
val locations = computedReferenceType.allLineLocations()
.dropWhile { it != location }
.drop(1)
.filter { isLocationSuitable(it) }
.filter(::isLocationSuitable)
.dropWhile { it.lineNumber() == location.lineNumber() }
for (locationAtLine in locations) {
@@ -378,7 +393,7 @@ fun getStepOverPosition(
return Action.STEP_OVER()
}
fun getStepOutPosition(
fun getStepOutAction(
location: Location,
suspendContext: SuspendContextImpl,
inlineFunctions: List<KtNamedFunction>,
+11
View File
@@ -0,0 +1,11 @@
LineBreakpoint created at asIterableInFor.kt:7
!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! asIterableInFor.AsIterableInForKt
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
asIterableInFor.kt:7
asIterableInFor.kt:8
asIterableInFor.kt:9
asIterableInFor.kt:8
asIterableInFor.kt:9
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 inlineCallInForRangeExpression.kt:7
!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! inlineCallInForRangeExpression.InlineCallInForRangeExpressionKt
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
inlineCallInForRangeExpression.kt:7
inlineCallInForRangeExpression.kt:8
inlineCallInForRangeExpression.kt:9
inlineCallInForRangeExpression.kt:8
inlineCallInForRangeExpression.kt:9
inlineCallInForRangeExpression.kt:8
inlineCallInForRangeExpression.kt:11
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
Process finished with exit code 0
@@ -0,0 +1,15 @@
package asIterableInFor
fun <T> nonInline(p: T): T = p
fun main(args: Array<String>) {
//Breakpoint!
val list = listOf("a", "b", "c")
for (element in list.asIterable()) {
nonInline(element)
}
}
// STEP_OVER: 4
// Tests that last line will be "9", no "11". See KT-13534.
@@ -0,0 +1,15 @@
package inlineCallInForRangeExpression
fun <T> nonInline(p: T) = p
fun main(args: Array<String>) {
//Breakpoint!
nonInline(12)
for (e in range()) {
nonInline(e)
}
}
inline fun range() = 1..2
// STEP_OVER: 6
@@ -373,6 +373,12 @@ public class KotlinSteppingTestGenerated extends AbstractKotlinSteppingTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/debugger/tinyApp/src/stepping/stepOver"), Pattern.compile("^([^.]+)\\.kt$"), true);
}
@TestMetadata("asIterableInFor.kt")
public void testAsIterableInFor() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepOver/asIterableInFor.kt");
doStepOverTest(fileName);
}
@TestMetadata("dexInlineInClass.kt")
public void testDexInlineInClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepOver/dexInlineInClass.kt");
@@ -403,6 +409,12 @@ public class KotlinSteppingTestGenerated extends AbstractKotlinSteppingTest {
doStepOverTest(fileName);
}
@TestMetadata("inlineCallInForRangeExpression.kt")
public void testInlineCallInForRangeExpression() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepOver/inlineCallInForRangeExpression.kt");
doStepOverTest(fileName);
}
@TestMetadata("inlineFunctionSameLines.kt")
public void testInlineFunctionSameLines() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepOver/inlineFunctionSameLines.kt");