[JVM_IR] Contain 'invokeSuspend' rewriting to the suspend function.

Do not rewrite returns in methods in nested lambda implementations.
That leads to unintended non-local returns from nested non-suspend
lambdas.
This commit is contained in:
Mads Ager
2019-10-16 13:50:12 +02:00
committed by Ilmir Usmanov
parent 78b9c082e7
commit 8be6a1fe8a
4 changed files with 7 additions and 3 deletions
@@ -187,6 +187,13 @@ private class AddContinuationLowering(private val context: JvmBackendContext) :
}
}
// If the suspend lambda body contains declarations of other classes (for other lambdas),
// do not rewrite those. In particular, that could lead to rewriting of returns in nested
// lambdas to unintended non-local returns.
override fun visitClass(declaration: IrClass): IrStatement {
return declaration
}
override fun visitReturn(expression: IrReturn): IrExpression {
val ret = super.visitReturn(expression) as IrReturn
return IrReturnImpl(ret.startOffset, ret.endOffset, context.irBuiltIns.anyType, function.symbol, ret.value)
-1
View File
@@ -1,5 +1,4 @@
// KJS_WITH_FULL_RUNTIME
// IGNORE_BACKEND: JVM_IR
// WITH_RUNTIME
// WITH_COROUTINES
// COMMON_COROUTINES_TEST
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
// WITH_RUNTIME
// WITH_COROUTINES
// COMMON_COROUTINES_TEST
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
// WITH_RUNTIME
// WITH_COROUTINES
// COMMON_COROUTINES_TEST