Skip to content

Commit 33b285f

Browse files
committed
Deprecate CoroutineDispatcher.invoke
Fixes #4199
1 parent 5ce2c90 commit 33b285f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

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

+9
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,16 @@ public suspend fun <T> withContext(
176176
* completes, and returns the result.
177177
*
178178
* This inline function calls [withContext].
179+
*
180+
* Deprecated, as this is very rarely used, surprising to those who do not already know about it,
181+
* and less idiomatic than `withContext(dispatcher) { ... }`.
182+
* See https://github.com/Kotlin/kotlinx.coroutines/issues/4199
179183
*/
184+
@Deprecated(
185+
message = "Use withContext(dispatcher) { ... }",
186+
level = DeprecationLevel.WARNING,
187+
replaceWith = ReplaceWith("withContext(this, block)"),
188+
) // WARNING since 1.9.0, was stable API before
180189
public suspend inline operator fun <T> CoroutineDispatcher.invoke(
181190
noinline block: suspend CoroutineScope.() -> T
182191
): T = withContext(this, block)

0 commit comments

Comments
 (0)