Skip to content

Commit ceca65f

Browse files
elizarovrecheej
authored andcommitted
Fixed CoroutinesScope.ensureActive docs (Kotlin#2242)
This is leftover from Kotlin#2044 fix. Fixes Kotlin#2241
1 parent 5953ac6 commit ceca65f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

kotlinx-coroutines-core/common/src/CoroutineScope.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -226,17 +226,19 @@ public fun CoroutineScope.cancel(message: String, cause: Throwable? = null): Uni
226226

227227
/**
228228
* Ensures that current scope is [active][CoroutineScope.isActive].
229-
* Throws [IllegalStateException] if the context does not have a job in it.
230229
*
231230
* If the job is no longer active, throws [CancellationException].
232231
* If the job was cancelled, thrown exception contains the original cancellation cause.
232+
* This function does not do anything if there is no [Job] in the scope's [coroutineContext][CoroutineScope.coroutineContext].
233233
*
234234
* This method is a drop-in replacement for the following code, but with more precise exception:
235235
* ```
236236
* if (!isActive) {
237237
* throw CancellationException()
238238
* }
239239
* ```
240+
*
241+
* @see CoroutineContext.ensureActive
240242
*/
241243
public fun CoroutineScope.ensureActive(): Unit = coroutineContext.ensureActive()
242244

0 commit comments

Comments
 (0)