[K/JS] Reset exceptionState inside coroutines with a finally block ^KT-58685 Fixed

This commit is contained in:
Artem Kobzar
2023-09-12 15:18:16 +00:00
committed by Space Team
parent 752ea6fd98
commit 7bc521ab92
8 changed files with 86 additions and 6 deletions
@@ -27,6 +27,8 @@ import org.jetbrains.kotlin.ir.util.setDeclarationsParent
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
import org.jetbrains.kotlin.name.Name
object FINALLY_EXPRESSION : IrStatementOriginImpl("FINALLY_EXPRESSION")
class FinallyBlocksLowering(val context: CommonBackendContext, private val throwableType: IrType): FileLoweringPass, IrElementTransformerVoidWithContext() {
private interface HighLevelJump {
@@ -271,13 +273,17 @@ class FinallyBlocksLowering(val context: CommonBackendContext, private val throw
+irReturnableBlock(symbol, type) {
+value
}
+copy(finallyExpression)
+irComposite(resultType = context.irBuiltIns.unitType, origin = FINALLY_EXPRESSION) {
+copy(finallyExpression)
}
}
else -> irBlock(value, null, type) {
val tmp = createTmpVariable(irReturnableBlock(symbol, type) {
+irReturn(symbol, value)
})
+copy(finallyExpression)
+irComposite(resultType = context.irBuiltIns.unitType, origin = FINALLY_EXPRESSION) {
+copy(finallyExpression)
}
+irGet(tmp)
}
}