Skip to content

Commit 2a05088

Browse files
authored
Promote deprecation levels for 1.7.0 (#3637)
1 parent bc9850e commit 2a05088

File tree

18 files changed

+44
-91
lines changed

18 files changed

+44
-91
lines changed

kotlinx-coroutines-core/api/kotlinx-coroutines-core.api

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -753,10 +753,10 @@ public final class kotlinx/coroutines/channels/ChannelsKt {
753753
public static final synthetic fun maxWith (Lkotlinx/coroutines/channels/ReceiveChannel;Ljava/util/Comparator;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
754754
public static final synthetic fun minWith (Lkotlinx/coroutines/channels/ReceiveChannel;Ljava/util/Comparator;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
755755
public static final synthetic fun none (Lkotlinx/coroutines/channels/ReceiveChannel;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
756-
public static final fun onReceiveOrNull (Lkotlinx/coroutines/channels/ReceiveChannel;)Lkotlinx/coroutines/selects/SelectClause1;
757-
public static final fun receiveOrNull (Lkotlinx/coroutines/channels/ReceiveChannel;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
756+
public static final synthetic fun onReceiveOrNull (Lkotlinx/coroutines/channels/ReceiveChannel;)Lkotlinx/coroutines/selects/SelectClause1;
757+
public static final synthetic fun receiveOrNull (Lkotlinx/coroutines/channels/ReceiveChannel;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
758758
public static final synthetic fun requireNoNulls (Lkotlinx/coroutines/channels/ReceiveChannel;)Lkotlinx/coroutines/channels/ReceiveChannel;
759-
public static final fun sendBlocking (Lkotlinx/coroutines/channels/SendChannel;Ljava/lang/Object;)V
759+
public static final synthetic fun sendBlocking (Lkotlinx/coroutines/channels/SendChannel;Ljava/lang/Object;)V
760760
public static final synthetic fun single (Lkotlinx/coroutines/channels/ReceiveChannel;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
761761
public static final synthetic fun singleOrNull (Lkotlinx/coroutines/channels/ReceiveChannel;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
762762
public static final synthetic fun take (Lkotlinx/coroutines/channels/ReceiveChannel;ILkotlin/coroutines/CoroutineContext;)Lkotlinx/coroutines/channels/ReceiveChannel;

kotlinx-coroutines-core/common/src/channels/Channel.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public interface SendChannel<in E> {
165165
level = DeprecationLevel.ERROR,
166166
message = "Deprecated in the favour of 'trySend' method",
167167
replaceWith = ReplaceWith("trySend(element).isSuccess")
168-
) // Warning since 1.5.0, error since 1.6.0
168+
) // Warning since 1.5.0, error since 1.6.0, not hidden until 1.8+ because API is quite widespread
169169
public fun offer(element: E): Boolean {
170170
val result = trySend(element)
171171
if (result.isSuccess) return true
@@ -329,7 +329,7 @@ public interface ReceiveChannel<out E> {
329329
"Please note that the provided replacement does not rethrow channel's close cause as 'poll' did, " +
330330
"for the precise replacement please refer to the 'poll' documentation",
331331
replaceWith = ReplaceWith("tryReceive().getOrNull()")
332-
) // Warning since 1.5.0, error since 1.6.0
332+
) // Warning since 1.5.0, error since 1.6.0, not hidden until 1.8+ because API is quite widespread
333333
public fun poll(): E? {
334334
val result = tryReceive()
335335
if (result.isSuccess) return result.getOrThrow()
@@ -361,7 +361,7 @@ public interface ReceiveChannel<out E> {
361361
"for the detailed replacement please refer to the 'receiveOrNull' documentation",
362362
level = DeprecationLevel.ERROR,
363363
replaceWith = ReplaceWith("receiveCatching().getOrNull()")
364-
) // Warning since 1.3.0, error in 1.5.0, will be hidden in 1.6.0
364+
) // Warning since 1.3.0, error in 1.5.0, cannot be hidden due to deprecated extensions
365365
public suspend fun receiveOrNull(): E? = receiveCatching().getOrNull()
366366

367367
/**

kotlinx-coroutines-core/common/src/channels/Channels.common.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,11 @@ public inline fun <E, R> BroadcastChannel<E>.consume(block: ReceiveChannel<E>.()
5252
@Deprecated(
5353
"Deprecated in the favour of 'receiveCatching'",
5454
ReplaceWith("receiveCatching().getOrNull()"),
55-
DeprecationLevel.ERROR
55+
DeprecationLevel.HIDDEN
5656
) // Warning since 1.5.0, ERROR in 1.6.0, HIDDEN in 1.7.0
5757
@Suppress("EXTENSION_SHADOWED_BY_MEMBER", "DEPRECATION_ERROR")
5858
public suspend fun <E : Any> ReceiveChannel<E>.receiveOrNull(): E? {
59+
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
5960
return (this as ReceiveChannel<E?>).receiveOrNull()
6061
}
6162

@@ -64,7 +65,7 @@ public suspend fun <E : Any> ReceiveChannel<E>.receiveOrNull(): E? {
6465
*/
6566
@Deprecated(
6667
"Deprecated in the favour of 'onReceiveCatching'",
67-
level = DeprecationLevel.ERROR
68+
level = DeprecationLevel.HIDDEN
6869
) // Warning since 1.5.0, ERROR in 1.6.0, HIDDEN in 1.7.0
6970
@Suppress("DEPRECATION_ERROR")
7071
public fun <E : Any> ReceiveChannel<E>.onReceiveOrNull(): SelectClause1<E?> {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ private class ChannelAsFlow<T>(
146146
*/
147147
@Suppress("DEPRECATION")
148148
@Deprecated(
149-
level = DeprecationLevel.WARNING,
149+
level = DeprecationLevel.ERROR,
150150
message = "'BroadcastChannel' is obsolete and all corresponding operators are deprecated " +
151151
"in the favour of StateFlow and SharedFlow"
152-
) // Since 1.5.0, was @FlowPreview, safe to remove in 1.8.0
152+
) // Since 1.5.0, ERROR since 1.7.0, was @FlowPreview, safe to remove in 1.8.0
153153
public fun <T> BroadcastChannel<T>.asFlow(): Flow<T> = flow {
154154
emitAll(openSubscription())
155155
}

kotlinx-coroutines-core/common/src/selects/Select.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public sealed interface SelectBuilder<in R> {
110110
@Deprecated(
111111
message = "Replaced with the same extension function",
112112
level = DeprecationLevel.ERROR, replaceWith = ReplaceWith(expression = "onTimeout", imports = ["kotlinx.coroutines.selects.onTimeout"])
113-
)
113+
) // Since 1.7.0, was experimental
114114
public fun onTimeout(timeMillis: Long, block: suspend () -> R): Unit = onTimeout(timeMillis, block)
115115
}
116116

kotlinx-coroutines-core/concurrent/src/channels/Channels.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ public fun <E> SendChannel<E>.trySendBlocking(element: E): ChannelResult<Unit> {
4444

4545
/** @suppress */
4646
@Deprecated(
47-
level = DeprecationLevel.ERROR,
47+
level = DeprecationLevel.HIDDEN,
4848
message = "Deprecated in the favour of 'trySendBlocking'. " +
4949
"Consider handling the result of 'trySendBlocking' explicitly and rethrow exception if necessary",
5050
replaceWith = ReplaceWith("trySendBlocking(element)")
51-
) // WARNING in 1.5.0, ERROR in 1.6.0, HIDDEN in 1.7.0
51+
) // WARNING in 1.5.0, ERROR in 1.6.0
5252
public fun <E> SendChannel<E>.sendBlocking(element: E) {
5353
// fast path
5454
if (trySend(element).isSuccess)

kotlinx-coroutines-core/jvm/test/flow/ConsumeAsFlowLeakTest.kt

Lines changed: 0 additions & 48 deletions
This file was deleted.

kotlinx-coroutines-test/common/src/TestBuilders.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ public fun runTest(
285285
ReplaceWith("runTest(context, timeout = dispatchTimeoutMs.milliseconds, testBody)",
286286
"kotlin.time.Duration.Companion.milliseconds"),
287287
DeprecationLevel.WARNING
288-
)
288+
) // Warning since 1.7.0, was experimental in 1.6.x
289289
public fun runTest(
290290
context: CoroutineContext = EmptyCoroutineContext,
291291
dispatchTimeoutMs: Long,
@@ -385,7 +385,7 @@ public fun TestScope.runTest(
385385
ReplaceWith("this.runTest(timeout = dispatchTimeoutMs.milliseconds, testBody)",
386386
"kotlin.time.Duration.Companion.milliseconds"),
387387
DeprecationLevel.WARNING
388-
)
388+
) // Warning since 1.7.0, was experimental in 1.6.x
389389
public fun TestScope.runTest(
390390
dispatchTimeoutMs: Long,
391391
testBody: suspend TestScope.() -> Unit

reactive/kotlinx-coroutines-reactive/api/kotlinx-coroutines-reactive.api

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ public final class kotlinx/coroutines/reactive/AwaitKt {
55
public static final fun awaitFirstOrNull (Lorg/reactivestreams/Publisher;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
66
public static final fun awaitLast (Lorg/reactivestreams/Publisher;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
77
public static final fun awaitSingle (Lorg/reactivestreams/Publisher;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
8-
public static final fun awaitSingleOrDefault (Lorg/reactivestreams/Publisher;Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
9-
public static final fun awaitSingleOrElse (Lorg/reactivestreams/Publisher;Lkotlin/jvm/functions/Function0;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
10-
public static final fun awaitSingleOrNull (Lorg/reactivestreams/Publisher;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
8+
public static final synthetic fun awaitSingleOrDefault (Lorg/reactivestreams/Publisher;Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
9+
public static final synthetic fun awaitSingleOrElse (Lorg/reactivestreams/Publisher;Lkotlin/jvm/functions/Function0;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
10+
public static final synthetic fun awaitSingleOrNull (Lorg/reactivestreams/Publisher;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
1111
}
1212

1313
public final class kotlinx/coroutines/reactive/ChannelKt {

reactive/kotlinx-coroutines-reactive/src/Await.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public suspend fun <T> Publisher<T>.awaitSingle(): T = awaitOne(Mode.SINGLE)
106106
@Deprecated(
107107
message = "Deprecated without a replacement due to its name incorrectly conveying the behavior. " +
108108
"Please consider using awaitFirstOrDefault().",
109-
level = DeprecationLevel.ERROR
109+
level = DeprecationLevel.HIDDEN
110110
) // Warning since 1.5, error in 1.6, hidden in 1.7
111111
public suspend fun <T> Publisher<T>.awaitSingleOrDefault(default: T): T = awaitOne(Mode.SINGLE_OR_DEFAULT, default)
112112

@@ -135,7 +135,7 @@ public suspend fun <T> Publisher<T>.awaitSingleOrDefault(default: T): T = awaitO
135135
message = "Deprecated without a replacement due to its name incorrectly conveying the behavior. " +
136136
"There is a specialized version for Reactor's Mono, please use that where applicable. " +
137137
"Alternatively, please consider using awaitFirstOrNull().",
138-
level = DeprecationLevel.ERROR,
138+
level = DeprecationLevel.HIDDEN,
139139
replaceWith = ReplaceWith("this.awaitSingleOrNull()", "kotlinx.coroutines.reactor")
140140
) // Warning since 1.5, error in 1.6, hidden in 1.7
141141
public suspend fun <T> Publisher<T>.awaitSingleOrNull(): T? = awaitOne(Mode.SINGLE_OR_DEFAULT)
@@ -164,7 +164,7 @@ public suspend fun <T> Publisher<T>.awaitSingleOrNull(): T? = awaitOne(Mode.SING
164164
@Deprecated(
165165
message = "Deprecated without a replacement due to its name incorrectly conveying the behavior. " +
166166
"Please consider using awaitFirstOrElse().",
167-
level = DeprecationLevel.ERROR
167+
level = DeprecationLevel.HIDDEN
168168
) // Warning since 1.5, error in 1.6, hidden in 1.7
169169
public suspend fun <T> Publisher<T>.awaitSingleOrElse(defaultValue: () -> T): T =
170170
awaitOne(Mode.SINGLE_OR_DEFAULT) ?: defaultValue()

0 commit comments

Comments
 (0)