2
2
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3
3
*/
4
4
5
+ @file:Suppress(" UNCHECKED_CAST" , " UNUSED_PARAMETER" )
6
+
5
7
package kotlinx.coroutines.channels
6
8
7
9
import kotlinx.atomicfu.*
@@ -16,6 +18,7 @@ import kotlin.jvm.*
16
18
/* *
17
19
* Abstract send channel. It is a base class for all send channel implementations.
18
20
*/
21
+ @Suppress(" UNCHECKED_CAST" , " UNUSED_PARAMETER" )
19
22
internal abstract class AbstractSendChannel <E >(
20
23
@JvmField protected val onUndeliveredElement : OnUndeliveredElement <E >?
21
24
) : SendChannel<E> {
@@ -122,7 +125,12 @@ internal abstract class AbstractSendChannel<E>(
122
125
return sendSuspend(element)
123
126
}
124
127
125
- @Suppress(" DEPRECATION" , " DEPRECATION_ERROR" )
128
+ @Suppress(" DEPRECATION_ERROR" )
129
+ @Deprecated(
130
+ level = DeprecationLevel .ERROR ,
131
+ message = " Deprecated in the favour of 'trySend' method" ,
132
+ replaceWith = ReplaceWith (" trySend(element).isSuccess" )
133
+ ) // see super()
126
134
override fun offer (element : E ): Boolean {
127
135
// Temporary migration for offer users who rely on onUndeliveredElement
128
136
try {
@@ -705,6 +713,11 @@ internal abstract class AbstractChannel<E>(
705
713
onCancellationConstructor = onUndeliveredElementReceiveCancellationConstructor
706
714
)
707
715
716
+ @Deprecated(
717
+ message = " Deprecated in favor of onReceiveCatching extension" ,
718
+ level = DeprecationLevel .ERROR ,
719
+ replaceWith = ReplaceWith (" onReceiveCatching" )
720
+ ) // See super()
708
721
override val onReceiveOrNull: SelectClause1 <E ?>
709
722
get() = SelectClause1Impl <E ?>(
710
723
clauseObject = this ,
@@ -726,7 +739,7 @@ internal abstract class AbstractChannel<E>(
726
739
if (selectResult is Closed <* >) throw selectResult.receiveException
727
740
else selectResult as E
728
741
729
- private fun processResultSelectReceiveCatching (ignoredParam : Any? , selectResult : Any? ): Any? =
742
+ private fun processResultSelectReceiveCatching (ignoredParam : Any? , selectResult : Any? ): Any =
730
743
if (selectResult is Closed <* >) ChannelResult .closed(selectResult.closeCause)
731
744
else ChannelResult .success(selectResult as E )
732
745
@@ -735,8 +748,8 @@ internal abstract class AbstractChannel<E>(
735
748
else selectResult as E
736
749
737
750
private val onUndeliveredElementReceiveCancellationConstructor: OnCancellationConstructor ? = onUndeliveredElement?.let {
738
- { select: SelectInstance <* >, ignoredParam : Any? , element: Any? ->
739
- { cause : Throwable -> if (element !is Closed <* >) onUndeliveredElement.callUndeliveredElement(element as E , select.context) }
751
+ { select: SelectInstance <* >, _ : Any? , element: Any? ->
752
+ { _ : Throwable -> if (element !is Closed <* >) onUndeliveredElement.callUndeliveredElement(element as E , select.context) }
740
753
}
741
754
}
742
755
0 commit comments