diff --git a/compiler/testData/codegen/box/coroutines/await.kt b/compiler/testData/codegen/box/coroutines/await.kt index b10b9474d8a..99d51454c01 100644 --- a/compiler/testData/codegen/box/coroutines/await.kt +++ b/compiler/testData/codegen/box/coroutines/await.kt @@ -54,7 +54,7 @@ private var log = "" private var inAwait = false -suspend fun await(value: Promise): S = suspendWithCurrentContinuation { continuation: Continuation -> +suspend fun await(value: Promise): S = CoroutineIntrinsics.suspendCoroutineOrReturn { continuation: Continuation -> if (inAwait) { throw IllegalStateException("Can't call await recursively") } @@ -65,7 +65,7 @@ suspend fun await(value: Promise): S = suspendWithCurrentContinuation { c } } inAwait = false - SUSPENDED + CoroutineIntrinsics.SUSPENDED } suspend fun awaitAndLog(value: Promise): S { diff --git a/compiler/testData/codegen/box/coroutines/beginWithException.kt b/compiler/testData/codegen/box/coroutines/beginWithException.kt index 912473df223..bcc6ec8b478 100644 --- a/compiler/testData/codegen/box/coroutines/beginWithException.kt +++ b/compiler/testData/codegen/box/coroutines/beginWithException.kt @@ -2,7 +2,7 @@ // WITH_COROUTINES import kotlin.coroutines.* -suspend fun suspendHere(): Any = suspendWithCurrentContinuation { x -> } +suspend fun suspendHere(): Any = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> } fun builder(c: suspend () -> Unit) { var exception: Throwable? = null diff --git a/compiler/testData/codegen/box/coroutines/beginWithExceptionNoHandleException.kt b/compiler/testData/codegen/box/coroutines/beginWithExceptionNoHandleException.kt index e5838d75936..fc1142ec9a5 100644 --- a/compiler/testData/codegen/box/coroutines/beginWithExceptionNoHandleException.kt +++ b/compiler/testData/codegen/box/coroutines/beginWithExceptionNoHandleException.kt @@ -1,7 +1,7 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* -suspend fun suspendHere(): Any = suspendWithCurrentContinuation { x ->} +suspend fun suspendHere(): Any = CoroutineIntrinsics.suspendCoroutineOrReturn { x ->} fun builder(c: suspend () -> Unit) { try { diff --git a/compiler/testData/codegen/box/coroutines/coercionToUnit.kt b/compiler/testData/codegen/box/coroutines/coercionToUnit.kt index 32308564194..ac01525766c 100644 --- a/compiler/testData/codegen/box/coroutines/coercionToUnit.kt +++ b/compiler/testData/codegen/box/coroutines/coercionToUnit.kt @@ -3,9 +3,9 @@ import kotlin.coroutines.* -suspend fun await(t: T): T = suspendWithCurrentContinuation { c -> +suspend fun await(t: T): T = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> c.resume(t) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } fun builder(c: suspend () -> Unit): String { diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/breakFinally.kt b/compiler/testData/codegen/box/coroutines/controlFlow/breakFinally.kt index 492b7a9bcd3..d49e8c0179c 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/breakFinally.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/breakFinally.kt @@ -6,9 +6,9 @@ import kotlin.coroutines.* class Controller { var result = "" - suspend fun suspendWithResult(value: T): T = suspendWithCurrentContinuation { c -> + suspend fun suspendWithResult(value: T): T = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> c.resume(value) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/breakStatement.kt b/compiler/testData/codegen/box/coroutines/controlFlow/breakStatement.kt index 9647d92b666..8aff6f5a2ff 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/breakStatement.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/breakStatement.kt @@ -6,9 +6,9 @@ import kotlin.coroutines.* class Controller { var result = "" - suspend fun suspendWithResult(value: T): T = suspendWithCurrentContinuation { c -> + suspend fun suspendWithResult(value: T): T = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> c.resume(value) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/doWhileStatement.kt b/compiler/testData/codegen/box/coroutines/controlFlow/doWhileStatement.kt index 75056773142..932fc621dd7 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/doWhileStatement.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/doWhileStatement.kt @@ -6,9 +6,9 @@ import kotlin.coroutines.* class Controller { var result = "" - suspend fun suspendWithResult(value: T): T = suspendWithCurrentContinuation { c -> + suspend fun suspendWithResult(value: T): T = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> c.resume(value) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/forContinue.kt b/compiler/testData/codegen/box/coroutines/controlFlow/forContinue.kt index 34ba99071e1..e1ff99af922 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/forContinue.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/forContinue.kt @@ -6,9 +6,9 @@ import kotlin.coroutines.* class Controller { var result = "" - suspend fun suspendWithResult(value: T): T = suspendWithCurrentContinuation { c -> + suspend fun suspendWithResult(value: T): T = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> c.resume(value) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/forStatement.kt b/compiler/testData/codegen/box/coroutines/controlFlow/forStatement.kt index e03fac1e285..5de02f0b5f4 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/forStatement.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/forStatement.kt @@ -6,9 +6,9 @@ import kotlin.coroutines.* class Controller { var result = "" - suspend fun suspendWithResult(value: T): T = suspendWithCurrentContinuation { c -> + suspend fun suspendWithResult(value: T): T = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> c.resume(value) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/ifStatement.kt b/compiler/testData/codegen/box/coroutines/controlFlow/ifStatement.kt index 02a0bfcc219..e7816fb694f 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/ifStatement.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/ifStatement.kt @@ -6,9 +6,9 @@ import kotlin.coroutines.* class Controller { var result = "" - suspend fun suspendWithResult(value: T): T = suspendWithCurrentContinuation { c -> + suspend fun suspendWithResult(value: T): T = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> c.resume(value) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/returnFromFinally.kt b/compiler/testData/codegen/box/coroutines/controlFlow/returnFromFinally.kt index dfff28e80b5..2453c6947b1 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/returnFromFinally.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/returnFromFinally.kt @@ -10,10 +10,10 @@ import kotlin.coroutines.* class Controller { var result = "" - suspend fun suspendAndLog(value: T): T = suspendWithCurrentContinuation { c -> + suspend fun suspendAndLog(value: T): T = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> result += "suspend($value);" c.resume(value) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/switchLikeWhen.kt b/compiler/testData/codegen/box/coroutines/controlFlow/switchLikeWhen.kt index 383ce99c611..cf386e60c97 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/switchLikeWhen.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/switchLikeWhen.kt @@ -6,10 +6,10 @@ import kotlin.coroutines.* class Controller { var result = "" - suspend fun suspendWithResult(value: T): T = suspendWithCurrentContinuation { c -> + suspend fun suspendWithResult(value: T): T = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> result += "[" c.resume(value) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/throwFromCatch.kt b/compiler/testData/codegen/box/coroutines/controlFlow/throwFromCatch.kt index 35bf5990651..ce70aa13d49 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/throwFromCatch.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/throwFromCatch.kt @@ -6,17 +6,17 @@ import kotlin.coroutines.* class Controller { var result = "" - suspend fun suspendAndLog(value: T): T = suspendWithCurrentContinuation { c -> + suspend fun suspendAndLog(value: T): T = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> result += "suspend($value);" c.resume(value) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } // Tail calls are not allowed to be Nothing typed. See KT-15051 - suspend fun suspendLogAndThrow(exception: Throwable): Any? = suspendWithCurrentContinuation { c -> + suspend fun suspendLogAndThrow(exception: Throwable): Any? = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> result += "throw(${exception.message});" c.resumeWithException(exception) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/throwInTryWithHandleResult.kt b/compiler/testData/codegen/box/coroutines/controlFlow/throwInTryWithHandleResult.kt index ae133566269..6fd8bd06afd 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/throwInTryWithHandleResult.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/throwInTryWithHandleResult.kt @@ -6,10 +6,10 @@ import kotlin.coroutines.* class Controller { var result = "" - suspend fun suspendAndLog(value: T): T = suspendWithCurrentContinuation { c -> + suspend fun suspendAndLog(value: T): T = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> result += "suspend($value);" c.resume(value) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/whileStatement.kt b/compiler/testData/codegen/box/coroutines/controlFlow/whileStatement.kt index 2b346f92658..bfd9670c2c8 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/whileStatement.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/whileStatement.kt @@ -6,9 +6,9 @@ import kotlin.coroutines.* class Controller { var result = "" - suspend fun suspendWithResult(value: T): T = suspendWithCurrentContinuation { c -> + suspend fun suspendWithResult(value: T): T = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> c.resume(value) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/controllerAccessFromInnerLambda.kt b/compiler/testData/codegen/box/coroutines/controllerAccessFromInnerLambda.kt index b45bcbc8b6f..d2ce1e4b381 100644 --- a/compiler/testData/codegen/box/coroutines/controllerAccessFromInnerLambda.kt +++ b/compiler/testData/codegen/box/coroutines/controllerAccessFromInnerLambda.kt @@ -4,9 +4,9 @@ import kotlin.coroutines.* class Controller { var result = false - suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume("OK") - SUSPENDED + CoroutineIntrinsics.SUSPENDED } fun foo() { diff --git a/compiler/testData/codegen/box/coroutines/defaultParametersInSuspend.kt b/compiler/testData/codegen/box/coroutines/defaultParametersInSuspend.kt index f62442290d5..c6feea4f052 100644 --- a/compiler/testData/codegen/box/coroutines/defaultParametersInSuspend.kt +++ b/compiler/testData/codegen/box/coroutines/defaultParametersInSuspend.kt @@ -3,9 +3,9 @@ import kotlin.coroutines.* class Controller { - suspend fun suspendHere(a: String = "abc", i: Int = 2): String = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(a: String = "abc", i: Int = 2): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(a + "#" + (i + 1)) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/interceptResume.kt b/compiler/testData/codegen/box/coroutines/dispatchResume.kt similarity index 65% rename from compiler/testData/codegen/box/coroutines/interceptResume.kt rename to compiler/testData/codegen/box/coroutines/dispatchResume.kt index 409411ebad3..c09f21dec45 100644 --- a/compiler/testData/codegen/box/coroutines/interceptResume.kt +++ b/compiler/testData/codegen/box/coroutines/dispatchResume.kt @@ -6,38 +6,38 @@ class Controller { var log = "" var resumeIndex = 0 - suspend fun suspendWithValue(value: T): T = suspendWithCurrentContinuation { continuation -> + suspend fun suspendWithValue(value: T): T = CoroutineIntrinsics.suspendCoroutineOrReturn { continuation -> log += "suspend($value);" continuation.resume(value) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } - suspend fun suspendWithException(value: String): Unit = suspendWithCurrentContinuation { continuation -> + suspend fun suspendWithException(value: String): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { continuation -> log += "error($value);" continuation.resumeWithException(RuntimeException(value)) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } fun test(c: suspend Controller.() -> Unit): String { val controller = Controller() - c.startCoroutine(controller, EmptyContinuation, object: ResumeInterceptor { - private fun interceptResume(block: () -> Unit) { + c.startCoroutine(controller, EmptyContinuation, object: ContinuationDispatcher { + private fun dispatchResume(block: () -> Unit) { val id = controller.resumeIndex++ controller.log += "before $id;" block() controller.log += "after $id;" } - override fun

interceptResume(data: P, continuation: Continuation

): Boolean { - interceptResume { + override fun

dispatchResume(data: P, continuation: Continuation

): Boolean { + dispatchResume { continuation.resume(data) } return true } - override fun interceptResumeWithException(exception: Throwable, continuation: Continuation<*>): Boolean { - interceptResume { + override fun dispatchResumeWithException(exception: Throwable, continuation: Continuation<*>): Boolean { + dispatchResume { continuation.resumeWithException(exception) } return true diff --git a/compiler/testData/codegen/box/coroutines/emptyClosure.kt b/compiler/testData/codegen/box/coroutines/emptyClosure.kt index ec7bd51ccb7..9a648c512c0 100644 --- a/compiler/testData/codegen/box/coroutines/emptyClosure.kt +++ b/compiler/testData/codegen/box/coroutines/emptyClosure.kt @@ -5,10 +5,10 @@ import kotlin.coroutines.* var result = 0 class Controller { - suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> result++ x.resume("OK") - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/falseUnitCoercion.kt b/compiler/testData/codegen/box/coroutines/falseUnitCoercion.kt index daf04bb26b0..a2a1d712017 100644 --- a/compiler/testData/codegen/box/coroutines/falseUnitCoercion.kt +++ b/compiler/testData/codegen/box/coroutines/falseUnitCoercion.kt @@ -3,9 +3,9 @@ import kotlin.coroutines.* class Controller { - suspend fun suspendHere(v: T): T = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(v: T): T = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(v) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/generate.kt b/compiler/testData/codegen/box/coroutines/generate.kt index 7872db5ada5..47c94806875 100644 --- a/compiler/testData/codegen/box/coroutines/generate.kt +++ b/compiler/testData/codegen/box/coroutines/generate.kt @@ -50,10 +50,10 @@ class GeneratedIterator(block: suspend Generator.() -> Unit) : AbstractIte override fun computeNext() { nextStep.resume(Unit) } - suspend override fun yield(value: T) = suspendWithCurrentContinuation { c -> + suspend override fun yield(value: T) = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> setNext(value) nextStep = c - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/handleException.kt b/compiler/testData/codegen/box/coroutines/handleException.kt index db68901a685..56935d5bbeb 100644 --- a/compiler/testData/codegen/box/coroutines/handleException.kt +++ b/compiler/testData/codegen/box/coroutines/handleException.kt @@ -6,20 +6,20 @@ class Controller { var exception: Throwable? = null val postponedActions = ArrayList<() -> Unit>() - suspend fun suspendWithValue(v: String): String = suspendWithCurrentContinuation { x -> + suspend fun suspendWithValue(v: String): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> postponedActions.add { x.resume(v) } - SUSPENDED + CoroutineIntrinsics.SUSPENDED } - suspend fun suspendWithException(e: Exception): String = suspendWithCurrentContinuation { x -> + suspend fun suspendWithException(e: Exception): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> postponedActions.add { x.resumeWithException(e) } - SUSPENDED + CoroutineIntrinsics.SUSPENDED } fun run(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/handleResultNonUnitExpression.kt b/compiler/testData/codegen/box/coroutines/handleResultNonUnitExpression.kt index 4355bfc05f4..0943e13080a 100644 --- a/compiler/testData/codegen/box/coroutines/handleResultNonUnitExpression.kt +++ b/compiler/testData/codegen/box/coroutines/handleResultNonUnitExpression.kt @@ -3,9 +3,9 @@ import kotlin.coroutines.* -suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> +suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume("OK") - SUSPENDED + CoroutineIntrinsics.SUSPENDED } fun builder(c: suspend () -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/handleResultSuspended.kt b/compiler/testData/codegen/box/coroutines/handleResultSuspended.kt index c064f78094e..c97385948e3 100644 --- a/compiler/testData/codegen/box/coroutines/handleResultSuspended.kt +++ b/compiler/testData/codegen/box/coroutines/handleResultSuspended.kt @@ -5,10 +5,10 @@ import kotlin.coroutines.* class Controller { var log = "" - suspend fun suspendAndLog(value: T): T = suspendWithCurrentContinuation { x -> + suspend fun suspendAndLog(value: T): T = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> log += "suspend($value);" x.resume(value) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/illegalState.kt b/compiler/testData/codegen/box/coroutines/illegalState.kt index 2a793ccc6bb..88cb58acb02 100644 --- a/compiler/testData/codegen/box/coroutines/illegalState.kt +++ b/compiler/testData/codegen/box/coroutines/illegalState.kt @@ -3,9 +3,9 @@ // TARGET_BACKEND: JVM import kotlin.coroutines.* -suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> +suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(Unit) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } fun builder1(c: suspend () -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/inlineSuspendFunction.kt b/compiler/testData/codegen/box/coroutines/inlineSuspendFunction.kt index e5ced90ddf2..ec2de0105a3 100644 --- a/compiler/testData/codegen/box/coroutines/inlineSuspendFunction.kt +++ b/compiler/testData/codegen/box/coroutines/inlineSuspendFunction.kt @@ -11,9 +11,9 @@ class Controller { x.resume(v) } - suspend inline fun suspendInline(v: String): String = suspendWithCurrentContinuation { x -> + suspend inline fun suspendInline(v: String): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> withValue(v, x) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } suspend inline fun suspendInline(crossinline b: () -> String): String = suspendInline(b()) diff --git a/compiler/testData/codegen/box/coroutines/inlinedTryCatchFinally.kt b/compiler/testData/codegen/box/coroutines/inlinedTryCatchFinally.kt index fa63d551ec1..43029d735ec 100644 --- a/compiler/testData/codegen/box/coroutines/inlinedTryCatchFinally.kt +++ b/compiler/testData/codegen/box/coroutines/inlinedTryCatchFinally.kt @@ -7,20 +7,20 @@ var wasCalled = false class Controller { val postponedActions = mutableListOf<() -> Unit>() - suspend fun suspendWithValue(v: String): String = suspendWithCurrentContinuation { x -> + suspend fun suspendWithValue(v: String): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> postponedActions.add { x.resume(v) } - SUSPENDED + CoroutineIntrinsics.SUSPENDED } - suspend fun suspendWithException(e: Exception): String = suspendWithCurrentContinuation { x -> + suspend fun suspendWithException(e: Exception): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> postponedActions.add { x.resumeWithException(e) } - SUSPENDED + CoroutineIntrinsics.SUSPENDED } fun run(c: suspend Controller.() -> String) { diff --git a/compiler/testData/codegen/box/coroutines/innerSuspensionCalls.kt b/compiler/testData/codegen/box/coroutines/innerSuspensionCalls.kt index 32394140a43..19de56f9200 100644 --- a/compiler/testData/codegen/box/coroutines/innerSuspensionCalls.kt +++ b/compiler/testData/codegen/box/coroutines/innerSuspensionCalls.kt @@ -4,9 +4,9 @@ import kotlin.coroutines.* class Controller { var i = 0 - suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume((i++).toString()) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/instanceOfContinuation.kt b/compiler/testData/codegen/box/coroutines/instanceOfContinuation.kt index 9baa09c2c8c..dab09664ad8 100644 --- a/compiler/testData/codegen/box/coroutines/instanceOfContinuation.kt +++ b/compiler/testData/codegen/box/coroutines/instanceOfContinuation.kt @@ -4,16 +4,16 @@ import kotlin.coroutines.* class Controller { - suspend fun runInstanceOf(): Boolean = suspendWithCurrentContinuation { x -> + suspend fun runInstanceOf(): Boolean = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> val y: Any = x x.resume(x is Continuation<*>) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } - suspend fun runCast(): Boolean = suspendWithCurrentContinuation { x -> + suspend fun runCast(): Boolean = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> val y: Any = x x.resume(Continuation::class.isInstance(y as Continuation<*>)) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/complicatedMerge.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/complicatedMerge.kt index 883c132adcf..86a5c981bac 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/complicatedMerge.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/complicatedMerge.kt @@ -3,9 +3,9 @@ import kotlin.coroutines.* class Controller { - suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(Unit) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/i2bResult.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/i2bResult.kt index 3845a14459a..32eaf28ec3f 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/i2bResult.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/i2bResult.kt @@ -3,9 +3,9 @@ import kotlin.coroutines.* class Controller { - suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(Unit) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromBooleanArray.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromBooleanArray.kt index 623a883ecbd..48bc273b3ea 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromBooleanArray.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromBooleanArray.kt @@ -3,9 +3,9 @@ import kotlin.coroutines.* class Controller { - suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(Unit) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromByteArray.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromByteArray.kt index c9a816c38f6..d9e615db484 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromByteArray.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromByteArray.kt @@ -3,9 +3,9 @@ import kotlin.coroutines.* class Controller { - suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(Unit) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/noVariableInTable.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/noVariableInTable.kt index 9f0e1e0f49a..5ba69a2ee1c 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/noVariableInTable.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/noVariableInTable.kt @@ -3,9 +3,9 @@ import kotlin.coroutines.* class Controller { - suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(Unit) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt index 348f37eed9a..87a8b21cbf7 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt @@ -3,9 +3,9 @@ import kotlin.coroutines.* class Controller { - suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(Unit) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInArrayStore.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInArrayStore.kt index f249490ddda..96eda9cfad5 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInArrayStore.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInArrayStore.kt @@ -4,9 +4,9 @@ import kotlin.coroutines.* class Controller { - suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(Unit) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInMethodCall.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInMethodCall.kt index 1164710b546..2de332b53a2 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInMethodCall.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInMethodCall.kt @@ -3,9 +3,9 @@ import kotlin.coroutines.* class Controller { - suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(Unit) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInPutfield.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInPutfield.kt index b282defd3f1..47aeadcf71d 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInPutfield.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInPutfield.kt @@ -4,9 +4,9 @@ import kotlin.coroutines.* class Controller { - suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(Unit) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInVarStore.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInVarStore.kt index 214bb2c002a..4568620869f 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInVarStore.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInVarStore.kt @@ -3,9 +3,9 @@ import kotlin.coroutines.* class Controller { - suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(Unit) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/iterateOverArray.kt b/compiler/testData/codegen/box/coroutines/iterateOverArray.kt index 8c4b170523a..a9bb1b5c742 100644 --- a/compiler/testData/codegen/box/coroutines/iterateOverArray.kt +++ b/compiler/testData/codegen/box/coroutines/iterateOverArray.kt @@ -3,9 +3,9 @@ import kotlin.coroutines.* class Controller { - suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume("OK") - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/kt12958.kt b/compiler/testData/codegen/box/coroutines/kt12958.kt index 50959fbcfb2..0ec9c8f8330 100644 --- a/compiler/testData/codegen/box/coroutines/kt12958.kt +++ b/compiler/testData/codegen/box/coroutines/kt12958.kt @@ -3,9 +3,9 @@ // WITH_CONTINUATION import kotlin.coroutines.* -suspend fun suspendHere(v: V): V = suspendWithCurrentContinuation { x -> +suspend fun suspendHere(v: V): V = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(v) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } fun builder(c: suspend () -> String): String { diff --git a/compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt b/compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt index 4e2e3b913dd..965ec182d8a 100644 --- a/compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt +++ b/compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt @@ -5,10 +5,10 @@ import kotlin.coroutines.* class Controller { var result = "" var ok = false - suspend fun suspendHere(v: String): Unit = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(v: String): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> result += v x.resume(Unit) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/lastStatementInc.kt b/compiler/testData/codegen/box/coroutines/lastStatementInc.kt index 33adaa438df..b24c04d1cb3 100644 --- a/compiler/testData/codegen/box/coroutines/lastStatementInc.kt +++ b/compiler/testData/codegen/box/coroutines/lastStatementInc.kt @@ -2,9 +2,9 @@ // WITH_COROUTINES import kotlin.coroutines.* -suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> +suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume("OK") - SUSPENDED + CoroutineIntrinsics.SUSPENDED } fun builder(c: suspend () -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/lastStementAssignment.kt b/compiler/testData/codegen/box/coroutines/lastStementAssignment.kt index d81faced79b..f04c11cede8 100644 --- a/compiler/testData/codegen/box/coroutines/lastStementAssignment.kt +++ b/compiler/testData/codegen/box/coroutines/lastStementAssignment.kt @@ -2,9 +2,9 @@ // WITH_COROUTINES import kotlin.coroutines.* -suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> +suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume("OK") - SUSPENDED + CoroutineIntrinsics.SUSPENDED } fun builder(c: suspend () -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/lastUnitExpression.kt b/compiler/testData/codegen/box/coroutines/lastUnitExpression.kt index 2a35ac3a787..79e7352fe06 100644 --- a/compiler/testData/codegen/box/coroutines/lastUnitExpression.kt +++ b/compiler/testData/codegen/box/coroutines/lastUnitExpression.kt @@ -5,10 +5,10 @@ import kotlin.coroutines.* class Controller { var ok = false var v = "fail" - suspend fun suspendHere(v: String): Unit = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(v: String): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> this.v = v x.resume(Unit) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/multiModule/simple.kt b/compiler/testData/codegen/box/coroutines/multiModule/simple.kt index 7bcbacfb037..3f7c8a605bc 100644 --- a/compiler/testData/codegen/box/coroutines/multiModule/simple.kt +++ b/compiler/testData/codegen/box/coroutines/multiModule/simple.kt @@ -7,9 +7,9 @@ package lib import kotlin.coroutines.* class Controller { - suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume("OK") - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/multipleInvokeCalls.kt b/compiler/testData/codegen/box/coroutines/multipleInvokeCalls.kt index 6de7143a57c..892ea72c0bd 100644 --- a/compiler/testData/codegen/box/coroutines/multipleInvokeCalls.kt +++ b/compiler/testData/codegen/box/coroutines/multipleInvokeCalls.kt @@ -5,9 +5,9 @@ import kotlin.coroutines.* class Controller { var lastSuspension: Continuation? = null var result = "fail" - suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> lastSuspension = x - SUSPENDED + CoroutineIntrinsics.SUSPENDED } fun hasNext() = lastSuspension != null diff --git a/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda1.kt b/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda1.kt index c192859f2d1..3926e11eb52 100644 --- a/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda1.kt +++ b/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda1.kt @@ -5,9 +5,9 @@ import kotlin.coroutines.* class Controller { var lastSuspension: Continuation? = null var result = "fail" - suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> lastSuspension = x - SUSPENDED + CoroutineIntrinsics.SUSPENDED } fun hasNext() = lastSuspension != null diff --git a/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda2.kt b/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda2.kt index 1ea6395e75e..fdf83f31294 100644 --- a/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda2.kt +++ b/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda2.kt @@ -5,9 +5,9 @@ import kotlin.coroutines.* class Controller { var lastSuspension: Continuation? = null var result = "fail" - suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> lastSuspension = x - SUSPENDED + CoroutineIntrinsics.SUSPENDED } fun hasNext() = lastSuspension != null diff --git a/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda3.kt b/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda3.kt index e96aee18076..5dac65520ee 100644 --- a/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda3.kt +++ b/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda3.kt @@ -5,9 +5,9 @@ import kotlin.coroutines.* class Controller { var lastSuspension: Continuation? = null var result = "fail" - suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> lastSuspension = x - SUSPENDED + CoroutineIntrinsics.SUSPENDED } fun hasNext() = lastSuspension != null diff --git a/compiler/testData/codegen/box/coroutines/nestedTryCatch.kt b/compiler/testData/codegen/box/coroutines/nestedTryCatch.kt index 04b147fa218..2e7b27f929e 100644 --- a/compiler/testData/codegen/box/coroutines/nestedTryCatch.kt +++ b/compiler/testData/codegen/box/coroutines/nestedTryCatch.kt @@ -7,20 +7,20 @@ var wasCalled = false class Controller { val postponedActions = ArrayList<() -> Unit>() - suspend fun suspendWithValue(v: String): String = suspendWithCurrentContinuation { x -> + suspend fun suspendWithValue(v: String): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> postponedActions.add { x.resume(v) } - SUSPENDED + CoroutineIntrinsics.SUSPENDED } - suspend fun suspendWithException(e: Exception): String = suspendWithCurrentContinuation { x -> + suspend fun suspendWithException(e: Exception): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> postponedActions.add { x.resumeWithException(e) } - SUSPENDED + CoroutineIntrinsics.SUSPENDED } fun run(c: suspend Controller.() -> String) { diff --git a/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambda.kt b/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambda.kt index 2a2aaf407bd..ac8d1592ed7 100644 --- a/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambda.kt +++ b/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambda.kt @@ -4,9 +4,9 @@ import kotlin.coroutines.* class Controller { var cResult = 0 - suspend fun suspendHere(v: Int): Int = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(v: Int): Int = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(v * 2) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambdaDeep.kt b/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambdaDeep.kt index fed77d76f53..9c0de6fadad 100644 --- a/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambdaDeep.kt +++ b/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambdaDeep.kt @@ -5,9 +5,9 @@ import kotlin.coroutines.* class Controller { var cResult = 0 - suspend fun suspendHere(v: Int): Int = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(v: Int): Int = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(v * 2) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/returnByLabel.kt b/compiler/testData/codegen/box/coroutines/returnByLabel.kt index b8ddd0c2e8e..583aa33bbc8 100644 --- a/compiler/testData/codegen/box/coroutines/returnByLabel.kt +++ b/compiler/testData/codegen/box/coroutines/returnByLabel.kt @@ -2,9 +2,9 @@ // WITH_COROUTINES import kotlin.coroutines.* -suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> +suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume("OK") - SUSPENDED + CoroutineIntrinsics.SUSPENDED } fun builder(c: suspend () -> Int): Int { diff --git a/compiler/testData/codegen/box/coroutines/simple.kt b/compiler/testData/codegen/box/coroutines/simple.kt index 4f68d5edb92..d640d67f0ba 100644 --- a/compiler/testData/codegen/box/coroutines/simple.kt +++ b/compiler/testData/codegen/box/coroutines/simple.kt @@ -2,9 +2,9 @@ // WITH_COROUTINES import kotlin.coroutines.* -suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> +suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume("OK") - SUSPENDED + CoroutineIntrinsics.SUSPENDED } fun builder(c: suspend () -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/simpleException.kt b/compiler/testData/codegen/box/coroutines/simpleException.kt index 80a1622a038..06999f19879 100644 --- a/compiler/testData/codegen/box/coroutines/simpleException.kt +++ b/compiler/testData/codegen/box/coroutines/simpleException.kt @@ -3,9 +3,9 @@ import kotlin.coroutines.* class Controller { - suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resumeWithException(RuntimeException("OK")) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/simpleWithHandleResult.kt b/compiler/testData/codegen/box/coroutines/simpleWithHandleResult.kt index 9ecfdae2a13..d6f61c1fee3 100644 --- a/compiler/testData/codegen/box/coroutines/simpleWithHandleResult.kt +++ b/compiler/testData/codegen/box/coroutines/simpleWithHandleResult.kt @@ -2,9 +2,9 @@ // WITH_COROUTINES import kotlin.coroutines.* -suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> +suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume("OK") - SUSPENDED + CoroutineIntrinsics.SUSPENDED } fun builder(c: suspend () -> Int): Int { diff --git a/compiler/testData/codegen/box/coroutines/stackUnwinding/suspendInCycle.kt b/compiler/testData/codegen/box/coroutines/stackUnwinding/suspendInCycle.kt index 7dbba4b82e9..7810fea43ec 100644 --- a/compiler/testData/codegen/box/coroutines/stackUnwinding/suspendInCycle.kt +++ b/compiler/testData/codegen/box/coroutines/stackUnwinding/suspendInCycle.kt @@ -3,10 +3,10 @@ import kotlin.coroutines.* class Controller { - suspend fun suspendHere(): Int = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): Int = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> 1 } - suspend fun suspendThere(): String = suspendWithCurrentContinuation { x -> + suspend fun suspendThere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> "?" } } diff --git a/compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt b/compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt index 552087ceeec..197969c80f2 100644 --- a/compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt +++ b/compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt @@ -3,9 +3,9 @@ import kotlin.coroutines.* var globalResult = "" -suspend fun suspendWithValue(v: String): String = suspendWithCurrentContinuation { x -> +suspend fun suspendWithValue(v: String): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(v) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } fun builder(c: suspend () -> String) { diff --git a/compiler/testData/codegen/box/coroutines/suspendDelegation.kt b/compiler/testData/codegen/box/coroutines/suspendDelegation.kt index 473588c4c65..7e0b04a51fc 100644 --- a/compiler/testData/codegen/box/coroutines/suspendDelegation.kt +++ b/compiler/testData/codegen/box/coroutines/suspendDelegation.kt @@ -5,9 +5,9 @@ import kotlin.coroutines.* class Controller { suspend fun suspendHere(): String = suspendThere() - suspend fun suspendThere(): String = suspendWithCurrentContinuation { x -> + suspend fun suspendThere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume("OK") - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/suspendFromInlineLambda.kt b/compiler/testData/codegen/box/coroutines/suspendFromInlineLambda.kt index b54775cce3e..f77e3ac11b4 100644 --- a/compiler/testData/codegen/box/coroutines/suspendFromInlineLambda.kt +++ b/compiler/testData/codegen/box/coroutines/suspendFromInlineLambda.kt @@ -3,9 +3,9 @@ import kotlin.coroutines.* class Controller { - suspend fun suspendHere(v: Int): Int = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(v: Int): Int = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(v * 2) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/suspendInCycle.kt b/compiler/testData/codegen/box/coroutines/suspendInCycle.kt index afb47bd0213..d59e9c44fcf 100644 --- a/compiler/testData/codegen/box/coroutines/suspendInCycle.kt +++ b/compiler/testData/codegen/box/coroutines/suspendInCycle.kt @@ -4,13 +4,13 @@ import kotlin.coroutines.* class Controller { var i = 0 - suspend fun suspendHere(): Int = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): Int = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(i++) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } - suspend fun suspendThere(): String = suspendWithCurrentContinuation { x -> + suspend fun suspendThere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume("?") - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/suspendInTheMiddleOfObjectConstruction.kt b/compiler/testData/codegen/box/coroutines/suspendInTheMiddleOfObjectConstruction.kt index d765256ab46..95114878c23 100644 --- a/compiler/testData/codegen/box/coroutines/suspendInTheMiddleOfObjectConstruction.kt +++ b/compiler/testData/codegen/box/coroutines/suspendInTheMiddleOfObjectConstruction.kt @@ -3,19 +3,19 @@ import kotlin.coroutines.* class Controller { - suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume("K") - SUSPENDED + CoroutineIntrinsics.SUSPENDED } - suspend fun suspendWithArgument(v: String): String = suspendWithCurrentContinuation { x -> + suspend fun suspendWithArgument(v: String): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(v) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } - suspend fun suspendWithDouble(v: Double): Double = suspendWithCurrentContinuation { x -> + suspend fun suspendWithDouble(v: Double): Double = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(v) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/tryCatchFinallyWithHandleResult.kt b/compiler/testData/codegen/box/coroutines/tryCatchFinallyWithHandleResult.kt index 32e11472980..c94ec80e3ba 100644 --- a/compiler/testData/codegen/box/coroutines/tryCatchFinallyWithHandleResult.kt +++ b/compiler/testData/codegen/box/coroutines/tryCatchFinallyWithHandleResult.kt @@ -7,20 +7,20 @@ var wasCalled = false class Controller { val postponedActions = ArrayList<() -> Unit>() - suspend fun suspendWithValue(v: String): String = suspendWithCurrentContinuation { x -> + suspend fun suspendWithValue(v: String): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> postponedActions.add { x.resume(v) } - SUSPENDED + CoroutineIntrinsics.SUSPENDED } - suspend fun suspendWithException(e: Exception): String = suspendWithCurrentContinuation { x -> + suspend fun suspendWithException(e: Exception): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> postponedActions.add { x.resumeWithException(e) } - SUSPENDED + CoroutineIntrinsics.SUSPENDED } fun run(c: suspend Controller.() -> String) { diff --git a/compiler/testData/codegen/box/coroutines/tryCatchWithHandleResult.kt b/compiler/testData/codegen/box/coroutines/tryCatchWithHandleResult.kt index 0180965b58c..8be35219df5 100644 --- a/compiler/testData/codegen/box/coroutines/tryCatchWithHandleResult.kt +++ b/compiler/testData/codegen/box/coroutines/tryCatchWithHandleResult.kt @@ -7,20 +7,20 @@ var wasCalled = false class Controller { val postponedActions = ArrayList<() -> Unit>() - suspend fun suspendWithValue(v: String): String = suspendWithCurrentContinuation { x -> + suspend fun suspendWithValue(v: String): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> postponedActions.add { x.resume(v) } - SUSPENDED + CoroutineIntrinsics.SUSPENDED } - suspend fun suspendWithException(e: Exception): String = suspendWithCurrentContinuation { x -> + suspend fun suspendWithException(e: Exception): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> postponedActions.add { x.resumeWithException(e) } - SUSPENDED + CoroutineIntrinsics.SUSPENDED } fun run(c: suspend Controller.() -> String) { diff --git a/compiler/testData/codegen/box/coroutines/tryFinallyInsideInlineLambda.kt b/compiler/testData/codegen/box/coroutines/tryFinallyInsideInlineLambda.kt index 302fe293b38..202481ee123 100644 --- a/compiler/testData/codegen/box/coroutines/tryFinallyInsideInlineLambda.kt +++ b/compiler/testData/codegen/box/coroutines/tryFinallyInsideInlineLambda.kt @@ -3,10 +3,10 @@ import kotlin.coroutines.* class Controller { - suspend fun suspendHere(v: String): String = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(v: String): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(v) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/tryFinallyWithHandleResult.kt b/compiler/testData/codegen/box/coroutines/tryFinallyWithHandleResult.kt index 8a8f5f909a0..c539516da92 100644 --- a/compiler/testData/codegen/box/coroutines/tryFinallyWithHandleResult.kt +++ b/compiler/testData/codegen/box/coroutines/tryFinallyWithHandleResult.kt @@ -7,20 +7,20 @@ var wasCalled = false class Controller { val postponedActions = mutableListOf<() -> Unit>() - suspend fun suspendWithValue(v: String): String = suspendWithCurrentContinuation { x -> + suspend fun suspendWithValue(v: String): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> postponedActions.add { x.resume(v) } - SUSPENDED + CoroutineIntrinsics.SUSPENDED } - suspend fun suspendWithException(e: Exception): String = suspendWithCurrentContinuation { x -> + suspend fun suspendWithException(e: Exception): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> postponedActions.add { x.resumeWithException(e) } - SUSPENDED + CoroutineIntrinsics.SUSPENDED } fun run(c: suspend Controller.() -> String) { diff --git a/compiler/testData/codegen/box/coroutines/varValueConflictsWithTable.kt b/compiler/testData/codegen/box/coroutines/varValueConflictsWithTable.kt index 02879c0c320..a0c7415d6aa 100644 --- a/compiler/testData/codegen/box/coroutines/varValueConflictsWithTable.kt +++ b/compiler/testData/codegen/box/coroutines/varValueConflictsWithTable.kt @@ -3,9 +3,9 @@ import kotlin.coroutines.* class Controller { - suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume("OK") - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/box/coroutines/varValueConflictsWithTableSameSort.kt b/compiler/testData/codegen/box/coroutines/varValueConflictsWithTableSameSort.kt index 8de5125aea9..d0eb7032a76 100644 --- a/compiler/testData/codegen/box/coroutines/varValueConflictsWithTableSameSort.kt +++ b/compiler/testData/codegen/box/coroutines/varValueConflictsWithTableSameSort.kt @@ -3,9 +3,9 @@ import kotlin.coroutines.* class Controller { - suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume("OK") - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/bytecodeListing/coroutineFields.kt b/compiler/testData/codegen/bytecodeListing/coroutineFields.kt index 92a3d0d5674..480410d1492 100644 --- a/compiler/testData/codegen/bytecodeListing/coroutineFields.kt +++ b/compiler/testData/codegen/bytecodeListing/coroutineFields.kt @@ -1,6 +1,6 @@ import kotlin.coroutines.* class Controller { - suspend fun suspendHere() = suspendWithCurrentContinuation { x -> + suspend fun suspendHere() = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume("OK") } } diff --git a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/complicatedMerge.kt b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/complicatedMerge.kt index c98d3c6256d..bdad437a9bf 100644 --- a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/complicatedMerge.kt +++ b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/complicatedMerge.kt @@ -4,9 +4,9 @@ import kotlin.coroutines.* class Controller { - suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(Unit) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/i2bResult.kt b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/i2bResult.kt index 6a20b8468d0..20efdec2df0 100644 --- a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/i2bResult.kt +++ b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/i2bResult.kt @@ -4,9 +4,9 @@ import kotlin.coroutines.* class Controller { - suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(Unit) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/loadFromBooleanArray.kt b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/loadFromBooleanArray.kt index c5cee8b75ca..70824cfeaae 100644 --- a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/loadFromBooleanArray.kt +++ b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/loadFromBooleanArray.kt @@ -4,9 +4,9 @@ import kotlin.coroutines.* class Controller { - suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(Unit) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/loadFromByteArray.kt b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/loadFromByteArray.kt index 8457a8c201d..3a98f01d6ac 100644 --- a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/loadFromByteArray.kt +++ b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/loadFromByteArray.kt @@ -4,9 +4,9 @@ import kotlin.coroutines.* class Controller { - suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(Unit) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/noVariableInTable.kt b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/noVariableInTable.kt index dd7d272e2d7..32705aba0b5 100644 --- a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/noVariableInTable.kt +++ b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/noVariableInTable.kt @@ -4,9 +4,9 @@ import kotlin.coroutines.* class Controller { - suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(Unit) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt index bd2441b8535..2980becbe55 100644 --- a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt +++ b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt @@ -4,9 +4,9 @@ import kotlin.coroutines.* class Controller { - suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(Unit) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInArrayStore.kt b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInArrayStore.kt index c38032aad72..8b9f38b9416 100644 --- a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInArrayStore.kt +++ b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInArrayStore.kt @@ -5,9 +5,9 @@ import kotlin.coroutines.* class Controller { - suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(Unit) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInMethodCall.kt b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInMethodCall.kt index 6b59a5a4dff..c4259f71a2f 100644 --- a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInMethodCall.kt +++ b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInMethodCall.kt @@ -4,9 +4,9 @@ import kotlin.coroutines.* class Controller { - suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(Unit) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInPutfield.kt b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInPutfield.kt index e585bb33e1c..d15591bf98a 100644 --- a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInPutfield.kt +++ b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInPutfield.kt @@ -5,9 +5,9 @@ import kotlin.coroutines.* class Controller { - suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(Unit) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInVarStore.kt b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInVarStore.kt index d781767ffb5..2f69ad8849a 100644 --- a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInVarStore.kt +++ b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInVarStore.kt @@ -4,9 +4,9 @@ import kotlin.coroutines.* class Controller { - suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> + suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume(Unit) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } } diff --git a/compiler/testData/codegen/bytecodeText/coroutines/varValueConflictsWithTable.kt b/compiler/testData/codegen/bytecodeText/coroutines/varValueConflictsWithTable.kt index 1bf3a1a1c1f..e1ac21d080b 100644 --- a/compiler/testData/codegen/bytecodeText/coroutines/varValueConflictsWithTable.kt +++ b/compiler/testData/codegen/bytecodeText/coroutines/varValueConflictsWithTable.kt @@ -2,7 +2,7 @@ // WITH_COROUTINES // TREAT_AS_ONE_FILE import kotlin.coroutines.* -suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> +suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume("OK") } diff --git a/compiler/testData/codegen/bytecodeText/coroutines/varValueConflictsWithTableSameSort.kt b/compiler/testData/codegen/bytecodeText/coroutines/varValueConflictsWithTableSameSort.kt index 452d4447d42..f7a36a4790b 100644 --- a/compiler/testData/codegen/bytecodeText/coroutines/varValueConflictsWithTableSameSort.kt +++ b/compiler/testData/codegen/bytecodeText/coroutines/varValueConflictsWithTableSameSort.kt @@ -2,7 +2,7 @@ // WITH_COROUTINES // TREAT_AS_ONE_FILE import kotlin.coroutines.* -suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> +suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume("OK") } diff --git a/compiler/testData/codegen/java8/box/async.kt b/compiler/testData/codegen/java8/box/async.kt index c62f08a70f0..e74ab41b80d 100644 --- a/compiler/testData/codegen/java8/box/async.kt +++ b/compiler/testData/codegen/java8/box/async.kt @@ -57,12 +57,12 @@ fun async(c: @Suspend() (() -> T)): CompletableFuture { return future } -suspend fun await(f: CompletableFuture) = suspendWithCurrentContinuation { machine -> +suspend fun await(f: CompletableFuture) = CoroutineIntrinsics.suspendCoroutineOrReturn { machine -> f.whenComplete { value, throwable -> if (throwable == null) machine.resume(value) else machine.resumeWithException(throwable) } - SUSPENDED + CoroutineIntrinsics.SUSPENDED } diff --git a/compiler/testData/codegen/java8/box/asyncException.kt b/compiler/testData/codegen/java8/box/asyncException.kt index 8af186c8b66..4ff64323157 100644 --- a/compiler/testData/codegen/java8/box/asyncException.kt +++ b/compiler/testData/codegen/java8/box/asyncException.kt @@ -54,12 +54,12 @@ fun async(c: @Suspend() (() -> T)): CompletableFuture { return future } -suspend fun await(f: CompletableFuture) = suspendWithCurrentContinuation { machine -> +suspend fun await(f: CompletableFuture) = CoroutineIntrinsics.suspendCoroutineOrReturn { machine -> f.whenComplete { value, throwable -> if (throwable == null) machine.resume(value) else machine.resumeWithException(throwable) } - SUSPENDED + CoroutineIntrinsics.SUSPENDED } diff --git a/compiler/testData/codegen/light-analysis/coroutines/interceptResume.txt b/compiler/testData/codegen/light-analysis/coroutines/dispatchResume.txt similarity index 100% rename from compiler/testData/codegen/light-analysis/coroutines/interceptResume.txt rename to compiler/testData/codegen/light-analysis/coroutines/dispatchResume.txt diff --git a/compiler/testData/compileKotlinAgainstKotlin/coroutinesBinary.kt b/compiler/testData/compileKotlinAgainstKotlin/coroutinesBinary.kt index 4f6614feeb5..ee796142d1c 100644 --- a/compiler/testData/compileKotlinAgainstKotlin/coroutinesBinary.kt +++ b/compiler/testData/compileKotlinAgainstKotlin/coroutinesBinary.kt @@ -1,7 +1,7 @@ // FILE: A.kt package a class Controller { - suspend fun suspendHere() = suspendWithCurrentContinuation { x -> + suspend fun suspendHere() = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> x.resume("OK") Suspend } diff --git a/compiler/testData/diagnostics/tests/coroutines/suspendWithCurrentContinuation.kt b/compiler/testData/diagnostics/tests/coroutines/suspendCoroutineOrReturn.kt similarity index 65% rename from compiler/testData/diagnostics/tests/coroutines/suspendWithCurrentContinuation.kt rename to compiler/testData/diagnostics/tests/coroutines/suspendCoroutineOrReturn.kt index 2a64a84db47..674e6aa8260 100644 --- a/compiler/testData/diagnostics/tests/coroutines/suspendWithCurrentContinuation.kt +++ b/compiler/testData/diagnostics/tests/coroutines/suspendCoroutineOrReturn.kt @@ -3,21 +3,21 @@ import kotlin.coroutines.* class Controller { - suspend fun noParams(): Unit = suspendWithCurrentContinuation { + suspend fun noParams(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { if (hashCode() % 2 == 0) { it.resume(Unit) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } else { Unit } } - suspend fun yieldString(value: String) = suspendWithCurrentContinuation { + suspend fun yieldString(value: String) = CoroutineIntrinsics.suspendCoroutineOrReturn { it.resume(1) it checkType { _>() } it.resume("") - // We can return anything here, 'suspendWithCurrentContinuation' is not very type-safe + // We can return anything here, 'CoroutineIntrinsics.suspendCoroutineOrReturn' is not very type-safe // Also we can call resume and then return the value too, but it's still just our problem "Not-int" } diff --git a/compiler/testData/diagnostics/tests/coroutines/suspendWithCurrentContinuation.txt b/compiler/testData/diagnostics/tests/coroutines/suspendCoroutineOrReturn.txt similarity index 100% rename from compiler/testData/diagnostics/tests/coroutines/suspendWithCurrentContinuation.txt rename to compiler/testData/diagnostics/tests/coroutines/suspendCoroutineOrReturn.txt diff --git a/compiler/testData/diagnostics/tests/coroutines/tailCalls/forbidden.kt b/compiler/testData/diagnostics/tests/coroutines/tailCalls/forbidden.kt index 39dc7dcc4a0..cb04b04e2d9 100644 --- a/compiler/testData/diagnostics/tests/coroutines/tailCalls/forbidden.kt +++ b/compiler/testData/diagnostics/tests/coroutines/tailCalls/forbidden.kt @@ -4,15 +4,15 @@ import kotlin.coroutines.* fun nonSuspend() {} suspend fun foo() { - suspendWithCurrentContinuation { x: Continuation -> } + CoroutineIntrinsics.suspendCoroutineOrReturn { x: Continuation -> } nonSuspend() } suspend fun unitSuspend() { - suspendWithCurrentContinuation { x: Continuation -> } + CoroutineIntrinsics.suspendCoroutineOrReturn { x: Continuation -> } } suspend fun baz(): Int = run { - suspendWithCurrentContinuation { x: Continuation -> } + CoroutineIntrinsics.suspendCoroutineOrReturn { x: Continuation -> } } diff --git a/compiler/testData/diagnostics/tests/coroutines/tailCalls/nothingTypedSuspendFunction.kt b/compiler/testData/diagnostics/tests/coroutines/tailCalls/nothingTypedSuspendFunction.kt index cac9fa549e7..30320a67f0e 100644 --- a/compiler/testData/diagnostics/tests/coroutines/tailCalls/nothingTypedSuspendFunction.kt +++ b/compiler/testData/diagnostics/tests/coroutines/tailCalls/nothingTypedSuspendFunction.kt @@ -1,7 +1,7 @@ // Tail calls are not allowed to be Nothing typed. See KT-15051 import kotlin.coroutines.* -suspend fun suspendLogAndThrow(exception: Throwable): Nothing = suspendWithCurrentContinuation { c -> +suspend fun suspendLogAndThrow(exception: Throwable): Nothing = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> c.resumeWithException(exception) - SUSPENDED + CoroutineIntrinsics.SUSPENDED } diff --git a/compiler/testData/diagnostics/tests/coroutines/tailCalls/tryCatch.kt b/compiler/testData/diagnostics/tests/coroutines/tailCalls/tryCatch.kt index 0b8d18d5349..8833b925b7b 100644 --- a/compiler/testData/diagnostics/tests/coroutines/tailCalls/tryCatch.kt +++ b/compiler/testData/diagnostics/tests/coroutines/tailCalls/tryCatch.kt @@ -7,7 +7,7 @@ suspend fun baz(): Int = 1 suspend fun tryCatch(): Int { return try { - suspendWithCurrentContinuation { x: Continuation -> } + CoroutineIntrinsics.suspendCoroutineOrReturn { x: Continuation -> } } catch (e: Exception) { baz() // another suspend function } @@ -15,7 +15,7 @@ suspend fun tryCatch(): Int { suspend fun tryFinally(): Int { return try { - suspendWithCurrentContinuation { x: Continuation -> } + CoroutineIntrinsics.suspendCoroutineOrReturn { x: Continuation -> } } finally { nonSuspend() } @@ -31,7 +31,7 @@ suspend fun returnInFinally(): Int { suspend fun tryCatchFinally(): Int { return try { - suspendWithCurrentContinuation { x: Continuation -> } + CoroutineIntrinsics.suspendCoroutineOrReturn { x: Continuation -> } } catch (e: Exception) { baz() // another suspend function } finally { diff --git a/compiler/testData/diagnostics/tests/coroutines/tailCalls/valid.kt b/compiler/testData/diagnostics/tests/coroutines/tailCalls/valid.kt index ab6504e7d1b..eaf1cec49f6 100644 --- a/compiler/testData/diagnostics/tests/coroutines/tailCalls/valid.kt +++ b/compiler/testData/diagnostics/tests/coroutines/tailCalls/valid.kt @@ -14,17 +14,17 @@ suspend fun bar1() { return if (1.hashCode() > 0) { foo() } - else suspendWithCurrentContinuation { x: Continuation -> } + else CoroutineIntrinsics.suspendCoroutineOrReturn { x: Continuation -> } } suspend fun bar2() = if (1.hashCode() > 0) { foo() } - else suspendWithCurrentContinuation { x: Continuation -> } + else CoroutineIntrinsics.suspendCoroutineOrReturn { x: Continuation -> } suspend fun bar3() = when { true -> { foo() } - else -> suspendWithCurrentContinuation { x: Continuation -> } + else -> CoroutineIntrinsics.suspendCoroutineOrReturn { x: Continuation -> } } diff --git a/jps-plugin/testData/incremental/inlineFunCallSite/coroutine/usage.kt b/jps-plugin/testData/incremental/inlineFunCallSite/coroutine/usage.kt index ec35bbd5b0c..cbadda3b8fc 100644 --- a/jps-plugin/testData/incremental/inlineFunCallSite/coroutine/usage.kt +++ b/jps-plugin/testData/incremental/inlineFunCallSite/coroutine/usage.kt @@ -5,7 +5,7 @@ fun async(coroutine x: Controller.() -> Continuation) { } class Controller { - suspend fun step(param: Int) = suspendWithCurrentContinuation { next -> + suspend fun step(param: Int) = CoroutineIntrinsics.suspendCoroutineOrReturn { next -> next.resume(param + 1) } }