Skip to content

Commit 5964290

Browse files
qwwdfsadpablobaxter
authored andcommitted
Properly implement replacement for Flow<T>.concatWith(flow) to avoid deadlocks when the downstream throws, but other flow has no elements in it (Kotlin#2659)
Fixes KT-46013
1 parent 36f4778 commit 5964290

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

kotlinx-coroutines-core/common/src/flow/Migration.kt

+6-6
Original file line numberDiff line numberDiff line change
@@ -344,13 +344,13 @@ public fun <T> Flow<T>.concatWith(value: T): Flow<T> = noImpl()
344344

345345
/**
346346
* Flow analogue of `concatWith` is [onCompletion].
347-
* Use `onCompletion { emitAll(other) }`.
347+
* Use `onCompletion { if (it == null) emitAll(other) }`.
348348
* @suppress
349349
*/
350350
@Deprecated(
351351
level = DeprecationLevel.ERROR,
352-
message = "Flow analogue of 'concatWith' is 'onCompletion'. Use 'onCompletion { emitAll(other) }'",
353-
replaceWith = ReplaceWith("onCompletion { emitAll(other) }")
352+
message = "Flow analogue of 'concatWith' is 'onCompletion'. Use 'onCompletion { if (it == null) emitAll(other) }'",
353+
replaceWith = ReplaceWith("onCompletion { if (it == null) emitAll(other) }")
354354
)
355355
public fun <T> Flow<T>.concatWith(other: Flow<T>): Flow<T> = noImpl()
356356

@@ -404,7 +404,7 @@ public fun <T1, T2, T3, T4, T5, R> Flow<T1>.combineLatest(
404404
* @suppress
405405
*/
406406
@Deprecated(
407-
level = DeprecationLevel.WARNING, // since 1.3.0, error in 1.4.0
407+
level = DeprecationLevel.ERROR, // since 1.3.0, error in 1.5.0
408408
message = "Use 'onStart { delay(timeMillis) }'",
409409
replaceWith = ReplaceWith("onStart { delay(timeMillis) }")
410410
)
@@ -416,7 +416,7 @@ public fun <T> Flow<T>.delayFlow(timeMillis: Long): Flow<T> = onStart { delay(ti
416416
* @suppress
417417
*/
418418
@Deprecated(
419-
level = DeprecationLevel.WARNING, // since 1.3.0, error in 1.4.0
419+
level = DeprecationLevel.ERROR, // since 1.3.0, error in 1.5.0
420420
message = "Use 'onEach { delay(timeMillis) }'",
421421
replaceWith = ReplaceWith("onEach { delay(timeMillis) }")
422422
)
@@ -430,7 +430,7 @@ public fun <T> Flow<T>.delayEach(timeMillis: Long): Flow<T> = onEach { delay(tim
430430
public fun <T, R> Flow<T>.switchMap(transform: suspend (value: T) -> Flow<R>): Flow<R> = flatMapLatest(transform)
431431

432432
@Deprecated(
433-
level = DeprecationLevel.WARNING, // Since 1.3.8, was experimental when deprecated
433+
level = DeprecationLevel.ERROR, // Warning since 1.3.8, was experimental when deprecated, ERROR since 1.5.0
434434
message = "'scanReduce' was renamed to 'runningReduce' to be consistent with Kotlin standard library",
435435
replaceWith = ReplaceWith("runningReduce(operation)")
436436
)

0 commit comments

Comments
 (0)