From 6d7ce6cec1d165010de43755d460385f1db29068 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Fri, 9 Jun 2017 16:00:13 +0300 Subject: [PATCH] Prevent debugger to stop twice on breakpoints after suspension point #KT-18453 In Progress --- .../coroutines/CoroutineTransformerMethodVisitor.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineTransformerMethodVisitor.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineTransformerMethodVisitor.kt index 1055ca9aef0..0f3241b5414 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineTransformerMethodVisitor.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineTransformerMethodVisitor.kt @@ -524,6 +524,12 @@ class CoroutineTransformerMethodVisitor( val afterSuspensionPointLineNumber = nextLineNumberNode?.line ?: suspendElementLineNumber visitLineNumber(afterSuspensionPointLineNumber, continuationLabelAfterLoadedResult.label) }) + + if (nextLineNumberNode != null) { + // Remove the line number instruction as it now covered with line number on continuation label. + // If both linenumber are present in bytecode, debugger will trigger line specific events twice. + remove(nextLineNumberNode) + } } return continuationLabel @@ -713,6 +719,7 @@ private fun findSafelyReachableReturns(methodNode: MethodNode): Array?> for (index in 0 until insns.size()) { if (insns[index].opcode == Opcodes.ARETURN) continue + @Suppress("RemoveExplicitTypeArguments") val newResult = controlFlowGraph .getSuccessorsIndices(index).plus(index)