Skip to content

Get rid of @InternalCoroutinesApi from Flow.collect member #3082

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion integration/kotlinx-coroutines-jdk8/src/stream/Stream.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public fun <T> Stream<T>.consumeAsFlow(): Flow<T> = StreamFlow(this)
private class StreamFlow<T>(private val stream: Stream<T>) : Flow<T> {
private val consumed = atomic(false)

@InternalCoroutinesApi
override suspend fun collect(collector: FlowCollector<T>) {
if (!consumed.compareAndSet(false, true)) error("Stream.consumeAsFlow can be collected only once")
try {
Expand Down
4 changes: 1 addition & 3 deletions kotlinx-coroutines-core/common/src/flow/Flow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ import kotlin.coroutines.*
*
* **The `Flow` interface is not stable for inheritance in 3rd party libraries**, as new methods
* might be added to this interface in the future, but is stable for use.
* Use the `flow { ... }` builder function to create an implementation.
* Use the `flow { ... }` builder function to create an implementation, or extend [AbstractFlow].
*/
public interface Flow<out T> {
/**
Expand All @@ -184,7 +184,6 @@ public interface Flow<out T> {
* should be used. Such limitation ensures that the context preservation property is not violated and prevents most
* of the developer mistakes related to concurrency, inconsistent flow dispatchers and cancellation.
*/
@InternalCoroutinesApi
public suspend fun collect(collector: FlowCollector<T>)
}

Expand Down Expand Up @@ -214,7 +213,6 @@ public interface Flow<out T> {
@FlowPreview
public abstract class AbstractFlow<T> : Flow<T>, CancellableFlow<T> {

@InternalCoroutinesApi
public final override suspend fun collect(collector: FlowCollector<T>) {
val safeCollector = SafeCollector(collector, coroutineContext)
try {
Expand Down
1 change: 0 additions & 1 deletion kotlinx-coroutines-core/common/src/flow/SharedFlow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ public interface SharedFlow<out T> : Flow<T> {
*
* @see [Flow.collect]
*/
@InternalCoroutinesApi
override suspend fun collect(collector: FlowCollector<T>): Nothing
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ private class DistinctFlowImpl<T>(
@JvmField val keySelector: (T) -> Any?,
@JvmField val areEquivalent: (old: Any?, new: Any?) -> Boolean
): Flow<T> {
@InternalCoroutinesApi
override suspend fun collect(collector: FlowCollector<T>) {
var previousKey: Any? = NULL
upstream.collect { value ->
Expand Down