Fix infinite loop in suspend function in case of return from finally [#KT-21961]
* add test
This commit is contained in:
committed by
Roman Artemev
parent
a81c06049a
commit
dec307799a
@@ -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
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -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");
|
||||
|
||||
+10
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user