Fix infinite loop in suspend function in case of return from finally [#KT-21961]

* add test
This commit is contained in:
Roman Artemev
2018-07-18 18:30:46 +03:00
committed by Roman Artemev
parent a81c06049a
commit dec307799a
8 changed files with 141 additions and 39 deletions
@@ -290,6 +290,8 @@ class CoroutineBodyTransformer(private val context: CoroutineTransformationConte
}
}
tryStack.removeAt(tryStack.lastIndex)
// Handle finally node
if (finallyNode != null) {
currentBlock = finallyBlock
@@ -298,8 +300,6 @@ class CoroutineBodyTransformer(private val context: CoroutineTransformationConte
hasFinallyBlocks = true
}
tryStack.removeAt(tryStack.lastIndex)
currentBlock = successor
}
@@ -5430,6 +5430,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/returnFromFinally.kt", "kotlin.coroutines.experimental");
}
@TestMetadata("returnWithFinally.kt")
public void testReturnWithFinally_1_2() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/returnWithFinally.kt", "kotlin.coroutines.experimental");
}
@TestMetadata("switchLikeWhen.kt")
public void testSwitchLikeWhen_1_2() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/switchLikeWhen.kt", "kotlin.coroutines.experimental");
@@ -5895,6 +5895,16 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/returnFromFinally.kt", "kotlin.coroutines");
}
@TestMetadata("returnWithFinally.kt")
public void testReturnWithFinally_1_2() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/returnWithFinally.kt", "kotlin.coroutines.experimental");
}
@TestMetadata("returnWithFinally.kt")
public void testReturnWithFinally_1_3() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/returnWithFinally.kt", "kotlin.coroutines");
}
@TestMetadata("switchLikeWhen.kt")
public void testSwitchLikeWhen_1_2() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/switchLikeWhen.kt", "kotlin.coroutines.experimental");