@@ -683,7 +683,7 @@ internal open class BufferedChannel<E>(
683
683
// If `receive()` decides to suspend, the corresponding
684
684
// `suspend` function that creates a continuation is called.
685
685
// The tail-call optimization is applied here.
686
- onNoWaiterSuspend = { segm, i, r -> unwrapTyped( receiveOnNoWaiterSuspend(segm, i, r) ) }
686
+ onNoWaiterSuspend = { segm, i, r -> receiveOnNoWaiterSuspend(segm, i, r) }
687
687
)
688
688
689
689
private suspend fun receiveOnNoWaiterSuspend (
@@ -706,8 +706,9 @@ internal open class BufferedChannel<E>(
706
706
// not dispatched yet. In case `onUndeliveredElement` is
707
707
// specified, we need to invoke it in the latter case.
708
708
onElementRetrieved = { element ->
709
- val onCancellation = onUndeliveredElement?.bindCancellationFun(unwrapTyped(element), cont.context)
710
- cont.resume(element, onCancellation)
709
+ val unwrapped: E = unwrapTyped(element)
710
+ val onCancellation = onUndeliveredElement?.bindCancellationFun(unwrapped, cont.context)
711
+ cont.resume(unwrapped, onCancellation)
711
712
},
712
713
onClosed = { onClosedReceiveOnNoWaiterSuspend(cont) },
713
714
)
@@ -737,7 +738,7 @@ internal open class BufferedChannel<E>(
737
738
},
738
739
onSuspend = { _, _, _ -> error(" unexpected" ) },
739
740
onClosed = { closed(closeCause) },
740
- onNoWaiterSuspend = { segm, i, r -> unwrapTyped( receiveCatchingOnNoWaiterSuspend(segm, i, r) ) }
741
+ onNoWaiterSuspend = { segm, i, r -> receiveCatchingOnNoWaiterSuspend(segm, i, r) }
741
742
)
742
743
743
744
private suspend fun receiveCatchingOnNoWaiterSuspend (
0 commit comments