Fix non-suspending labeled loop in suspend function

Fix bug when labeled loop, which does not contain suspend calls
in its body, was losing its label
This commit is contained in:
Alexey Andreev
2017-04-27 17:37:17 +03:00
parent 6047746c90
commit c8c3d24b45
6 changed files with 82 additions and 1 deletions
@@ -93,7 +93,14 @@ class CoroutineBodyTransformer(private val program: JsProgram, private val conte
when (inner) {
is JsWhile,
is JsDoWhile,
is JsFor -> inner.accept(this)
is JsFor -> {
if (x in nodesToSplit) {
inner.accept(this)
}
else {
currentStatements += x
}
}
else -> splitIfNecessary(x) {
val successor = CoroutineBlock()
@@ -6077,6 +6077,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
doTest(fileName);
}
@TestMetadata("labeledWhile.kt")
public void testLabeledWhile() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/controlFlow/labeledWhile.kt");
doTest(fileName);
}
@TestMetadata("returnFromFinally.kt")
public void testReturnFromFinally() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/controlFlow/returnFromFinally.kt");