From 3449848215160dd6d438281082240040e2fa682b Mon Sep 17 00:00:00 2001 From: Roman Elizarov Date: Fri, 11 Sep 2020 11:22:29 +0300 Subject: [PATCH] Fixed CoroutinesScope.ensureActive docs This is leftover from #2044 fix. Fixes #2241 --- kotlinx-coroutines-core/common/src/CoroutineScope.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kotlinx-coroutines-core/common/src/CoroutineScope.kt b/kotlinx-coroutines-core/common/src/CoroutineScope.kt index 7dbd6a6d7b..0dde6c9352 100644 --- a/kotlinx-coroutines-core/common/src/CoroutineScope.kt +++ b/kotlinx-coroutines-core/common/src/CoroutineScope.kt @@ -226,10 +226,10 @@ public fun CoroutineScope.cancel(message: String, cause: Throwable? = null): Uni /** * Ensures that current scope is [active][CoroutineScope.isActive]. - * Throws [IllegalStateException] if the context does not have a job in it. * * If the job is no longer active, throws [CancellationException]. * If the job was cancelled, thrown exception contains the original cancellation cause. + * This function does not do anything if there is no [Job] in the scope's [coroutineContext][CoroutineScope.coroutineContext]. * * This method is a drop-in replacement for the following code, but with more precise exception: * ``` @@ -237,6 +237,8 @@ public fun CoroutineScope.cancel(message: String, cause: Throwable? = null): Uni * throw CancellationException() * } * ``` + * + * @see CoroutineContext.ensureActive */ public fun CoroutineScope.ensureActive(): Unit = coroutineContext.ensureActive()