diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt index e133a14e8d5..14e2f7e657d 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt @@ -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) diff --git a/compiler/testData/codegen/box/coroutines/await.kt b/compiler/testData/codegen/box/coroutines/await.kt index 5b400287cc3..a47acf9136e 100644 --- a/compiler/testData/codegen/box/coroutines/await.kt +++ b/compiler/testData/codegen/box/coroutines/await.kt @@ -1,5 +1,4 @@ // KJS_WITH_FULL_RUNTIME -// IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES // COMMON_COROUTINES_TEST diff --git a/compiler/testData/codegen/box/coroutines/controllerAccessFromInnerLambda.kt b/compiler/testData/codegen/box/coroutines/controllerAccessFromInnerLambda.kt index 329347403c2..4072acf4bed 100644 --- a/compiler/testData/codegen/box/coroutines/controllerAccessFromInnerLambda.kt +++ b/compiler/testData/codegen/box/coroutines/controllerAccessFromInnerLambda.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES // COMMON_COROUTINES_TEST diff --git a/compiler/testData/codegen/box/coroutines/featureIntersection/tailrec/realIteratorFoldl.kt b/compiler/testData/codegen/box/coroutines/featureIntersection/tailrec/realIteratorFoldl.kt index b9831a52341..17871dd2a1b 100644 --- a/compiler/testData/codegen/box/coroutines/featureIntersection/tailrec/realIteratorFoldl.kt +++ b/compiler/testData/codegen/box/coroutines/featureIntersection/tailrec/realIteratorFoldl.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES // COMMON_COROUTINES_TEST