diff --git a/backend.native/tests/objcexport/coroutines.kt b/backend.native/tests/objcexport/coroutines.kt index 854f2d9101a..0e7b291c23a 100644 --- a/backend.native/tests/objcexport/coroutines.kt +++ b/backend.native/tests/objcexport/coroutines.kt @@ -6,6 +6,7 @@ package coroutines import kotlin.coroutines.* +import kotlin.coroutines.cancellation.CancellationException import kotlin.coroutines.intrinsics.* import kotlin.native.concurrent.isFrozen import kotlin.native.internal.ObjCErrorException @@ -15,7 +16,7 @@ class CoroutineException : Throwable() suspend fun suspendFun() = 42 -@Throws(CoroutineException::class) +@Throws(CoroutineException::class, CancellationException::class) suspend fun suspendFun(result: Any?, doSuspend: Boolean, doThrow: Boolean): Any? { if (doSuspend) { suspendCoroutineUninterceptedOrReturn { @@ -41,20 +42,20 @@ class ContinuationHolder { } } -@Throws(CoroutineException::class) +@Throws(CoroutineException::class, CancellationException::class) suspend fun suspendFunAsync(result: Any?, continuationHolder: ContinuationHolder): Any? = suspendCoroutineUninterceptedOrReturn { continuationHolder.continuation = it COROUTINE_SUSPENDED } ?: result -@Throws(CoroutineException::class) +@Throws(CoroutineException::class, CancellationException::class) fun throwException(exception: Throwable) { throw exception } interface SuspendFun { - @Throws(CoroutineException::class) + @Throws(CoroutineException::class, CancellationException::class) suspend fun suspendFun(doYield: Boolean, doThrow: Boolean): Int } @@ -84,7 +85,7 @@ fun callSuspendFun(suspendFun: SuspendFun, doYield: Boolean, doThrow: Boolean, r .startCoroutine(ResultHolderCompletion(resultHolder)) } -@Throws(CoroutineException::class) +@Throws(CoroutineException::class, CancellationException::class) suspend fun callSuspendFun2(suspendFun: SuspendFun, doYield: Boolean, doThrow: Boolean): Int { return suspendFun.suspendFun(doYield = doYield, doThrow = doThrow) } @@ -96,10 +97,10 @@ interface SuspendBridge { suspend fun unit(value: T): Unit suspend fun unitAsAny(value: T): Any? - @Throws(CoroutineException::class) suspend fun nothing(value: T): Nothing - @Throws(CoroutineException::class) suspend fun nothingAsInt(value: T): Int - @Throws(CoroutineException::class) suspend fun nothingAsAny(value: T): Any? - @Throws(CoroutineException::class) suspend fun nothingAsUnit(value: T): Unit + @Throws(Throwable::class) suspend fun nothing(value: T): Nothing + @Throws(Throwable::class) suspend fun nothingAsInt(value: T): Int + @Throws(Throwable::class) suspend fun nothingAsAny(value: T): Any? + @Throws(Throwable::class) suspend fun nothingAsUnit(value: T): Unit } abstract class AbstractSuspendBridge : SuspendBridge { @@ -132,7 +133,7 @@ private suspend fun callAbstractSuspendBridgeImpl(bridge: AbstractSuspendBridge) assertFailsWith { bridge.nothingAsUnit(10) } } -@Throws(CoroutineException::class) +@Throws(Throwable::class) fun callSuspendBridge(bridge: AbstractSuspendBridge, resultHolder: ResultHolder) { suspend { callSuspendBridgeImpl(bridge)