diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/NameTables.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/NameTables.kt index 48c3dfdf6bb..3af60e3a1cd 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/NameTables.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/NameTables.kt @@ -304,7 +304,7 @@ class LocalNameGenerator(parentScope: NameScope) : IrElementVisitorVoid { val localLoopNames = NameTable() val localReturnableBlockNames = NameTable() - private val breakableDeque: Deque = LinkedList() + private val jumpableDeque: Deque = LinkedList() override fun visitElement(element: IrElement) { element.acceptChildrenVoid(this) @@ -319,13 +319,22 @@ class LocalNameGenerator(parentScope: NameScope) : IrElementVisitorVoid { override fun visitBreak(jump: IrBreak) { val loop = jump.loop - if (loop.label == null && loop != breakableDeque.firstOrNull()) { + if (loop.label == null && loop != jumpableDeque.firstOrNull()) { persistLoopName(SYNTHETIC_LOOP_LABEL, loop) } super.visitBreak(jump) } + override fun visitContinue(jump: IrContinue) { + val loop = jump.loop + if (loop.label == null && loop != jumpableDeque.firstOrNull()) { + persistLoopName(SYNTHETIC_LOOP_LABEL, loop) + } + + super.visitContinue(jump) + } + override fun visitReturn(expression: IrReturn) { val targetSymbol = expression.returnTargetSymbol if (targetSymbol is IrReturnableBlockSymbol) { @@ -336,19 +345,19 @@ class LocalNameGenerator(parentScope: NameScope) : IrElementVisitorVoid { } override fun visitWhen(expression: IrWhen) { - breakableDeque.push(expression) + jumpableDeque.push(expression) super.visitWhen(expression) - breakableDeque.pop() + jumpableDeque.pop() } override fun visitLoop(loop: IrLoop) { - breakableDeque.push(loop) + jumpableDeque.push(loop) super.visitLoop(loop) - breakableDeque.pop() + jumpableDeque.pop() val label = loop.label @@ -384,5 +393,5 @@ fun sanitizeName(name: String): String { return builder.toString() } -private const val SYNTHETIC_LOOP_LABEL = "\$l\$break" +private const val SYNTHETIC_LOOP_LABEL = "\$l\$loop" private const val SYNTHETIC_BLOCK_LABEL = "\$l\$block" diff --git a/compiler/testData/codegen/box/diagnostics/functions/tailRecursion/recursiveCallInInlineLambdaWithCapture.kt b/compiler/testData/codegen/box/diagnostics/functions/tailRecursion/recursiveCallInInlineLambdaWithCapture.kt index 53cd5e78da9..580a218b1b8 100644 --- a/compiler/testData/codegen/box/diagnostics/functions/tailRecursion/recursiveCallInInlineLambdaWithCapture.kt +++ b/compiler/testData/codegen/box/diagnostics/functions/tailRecursion/recursiveCallInInlineLambdaWithCapture.kt @@ -1,5 +1,5 @@ // KT-14961 -// IGNORE_BACKEND: JVM, JS_IR +// IGNORE_BACKEND: JVM // WITH_RUNTIME fun listOfFactor(number: Int): List {