Skip to content

Commit 36065e6

Browse files
authored
Restore TCO in BufferedChannel (#3627)
1 parent fc6c811 commit 36065e6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ internal open class BufferedChannel<E>(
130130
onNoWaiterSuspend = { segm, i, elem, s -> sendOnNoWaiterSuspend(segm, i, elem, s) }
131131
)
132132

133-
private suspend fun onClosedSend(element: E): Nothing = suspendCancellableCoroutine { continuation ->
133+
// NB: return type could've been Nothing, but it breaks TCO
134+
private suspend fun onClosedSend(element: E): Unit = suspendCancellableCoroutine { continuation ->
134135
onUndeliveredElement?.callUndeliveredElementCatchingException(element)?.let {
135136
// If it crashes, add send exception as suppressed for better diagnostics
136137
it.addSuppressed(sendException)

0 commit comments

Comments
 (0)