@@ -302,9 +302,18 @@ public interface ReceiveChannel<out E> {
302
302
* * Its name was not aligned with the rest of the API and tried to mimic Java's queue instead.
303
303
*
304
304
* See https://github.com/Kotlin/kotlinx.coroutines/issues/974 for more context.
305
+ *
306
+ * ### Replacement note
307
+ *
308
+ * The replacement `tryReceive().getOrNull()` is a default that ignores all close exceptions and
309
+ * proceeds with `null`, while `poll` throws an exception if the channel was closed with an exception.
310
+ * Replacement with the very same 'poll' semantics is `tryReceive().onClosed { if (it != null) throw it }.getOrNull()`
305
311
*/
306
- @Deprecated(level = DeprecationLevel .WARNING ,
307
- message = " Deprecated in the favour of 'tryReceive'" ,
312
+ @Deprecated(
313
+ level = DeprecationLevel .WARNING ,
314
+ message = " Deprecated in the favour of 'tryReceive'. " +
315
+ " Please note that the provided replacement does not rethrow channel's close cause as 'poll' did, " +
316
+ " for the precise replacement please refer to the 'poll' documentation" ,
308
317
replaceWith = ReplaceWith (" tryReceive().getOrNull()" )
309
318
) // Warning since 1.5.0
310
319
public fun poll (): E ? {
@@ -322,12 +331,18 @@ public interface ReceiveChannel<out E> {
322
331
* - Was throwing if the channel has failed even though its signature may suggest it returns 'null'
323
332
* - It didn't really belong to core channel API and can be exposed as an extension instead.
324
333
*
325
- * @suppress doc
334
+ * ### Replacement note
335
+ *
336
+ * The replacement `receiveCatching().getOrNull()` is a safe default that ignores all close exceptions and
337
+ * proceeds with `null`, while `receiveOrNull` throws an exception if the channel was closed with an exception.
338
+ * Replacement with the very same `receiveOrNull` semantics is `receiveCatching().onClosed { if (it != null) throw it }.getOrNull()`.
326
339
*/
327
340
@Suppress(" INVISIBLE_REFERENCE" , " INVISIBLE_MEMBER" )
328
341
@LowPriorityInOverloadResolution
329
342
@Deprecated(
330
- message = " Deprecated in favor of receiveCatching" ,
343
+ message = " Deprecated in favor of 'receiveCatching'. " +
344
+ " Please note that the provided replacement does not rethrow channel's close cause as 'receiveOrNull' did, " +
345
+ " for the detailed replacement please refer to the 'receiveOrNull' documentation" ,
331
346
level = DeprecationLevel .ERROR ,
332
347
replaceWith = ReplaceWith (" receiveCatching().getOrNull()" )
333
348
) // Warning since 1.3.0, error in 1.5.0, will be hidden in 1.6.0
0 commit comments