diff --git a/kotlinx-coroutines-core/api/kotlinx-coroutines-core.api b/kotlinx-coroutines-core/api/kotlinx-coroutines-core.api index a910db9a56..6df47e179f 100644 --- a/kotlinx-coroutines-core/api/kotlinx-coroutines-core.api +++ b/kotlinx-coroutines-core/api/kotlinx-coroutines-core.api @@ -987,7 +987,6 @@ public abstract class kotlinx/coroutines/flow/internal/ChannelFlow : kotlinx/cor public fun collect (Lkotlinx/coroutines/flow/FlowCollector;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; protected abstract fun collectTo (Lkotlinx/coroutines/channels/ProducerScope;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; protected abstract fun create (Lkotlin/coroutines/CoroutineContext;I)Lkotlinx/coroutines/flow/internal/ChannelFlow; - protected final fun getProduceCapacity ()I public fun produceImpl (Lkotlinx/coroutines/CoroutineScope;)Lkotlinx/coroutines/channels/ReceiveChannel; public fun toString ()Ljava/lang/String; public final fun update (Lkotlin/coroutines/CoroutineContext;I)Lkotlinx/coroutines/flow/internal/ChannelFlow; diff --git a/kotlinx-coroutines-core/common/src/flow/Builders.kt b/kotlinx-coroutines-core/common/src/flow/Builders.kt index af5e9dc133..d8e82d65ff 100644 --- a/kotlinx-coroutines-core/common/src/flow/Builders.kt +++ b/kotlinx-coroutines-core/common/src/flow/Builders.kt @@ -298,8 +298,8 @@ public fun channelFlow(@BuilderInference block: suspend ProducerScope.() * } * api.register(callback) * /* - * * Suspends until either 'onCompleted' from the callback is invoked - * * or flow collector is cancelled (e.g. by 'take(1)' or because a collector's activity was destroyed). + * * Suspends until either 'onCompleted'/'onApiError' from the callback is invoked + * * or flow collector is cancelled (e.g. by 'take(1)' or because a collector's coroutine was cancelled). * * In both cases, callback will be properly unregistered. * */ * awaitClose { api.unregister(callback) } @@ -342,8 +342,8 @@ private class CallbackFlowBuilder( throw IllegalStateException( """ 'awaitClose { yourCallbackOrListener.cancel() }' should be used in the end of callbackFlow block. - Otherwise, a callback/listener may leak in case of cancellation external cancellation (e.g. by 'take(1)' or destroyed activity). - See callbackFlow API documentation for the details. + Otherwise, a callback/listener may leak in case of external cancellation. + See callbackFlow API documentation for the details. """.trimIndent() ) } diff --git a/kotlinx-coroutines-core/common/src/flow/internal/ChannelFlow.kt b/kotlinx-coroutines-core/common/src/flow/internal/ChannelFlow.kt index 40df591632..8b79c09b6e 100644 --- a/kotlinx-coroutines-core/common/src/flow/internal/ChannelFlow.kt +++ b/kotlinx-coroutines-core/common/src/flow/internal/ChannelFlow.kt @@ -32,7 +32,7 @@ public abstract class ChannelFlow( internal val collectToFun: suspend (ProducerScope) -> Unit get() = { collectTo(it) } - protected val produceCapacity: Int + private val produceCapacity: Int get() = if (capacity == Channel.OPTIONAL_CHANNEL) Channel.BUFFERED else capacity public fun update(