Skip to content

Commit 48aa354

Browse files
authored
Get rid of @InternalCoroutinesApi from Flow.collect member (#3082)
* Get rid of @InternalCoroutinesApi from Flow.collect member Fixes #3078
1 parent d220071 commit 48aa354

File tree

4 files changed

+1
-6
lines changed

4 files changed

+1
-6
lines changed

integration/kotlinx-coroutines-jdk8/src/stream/Stream.kt

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public fun <T> Stream<T>.consumeAsFlow(): Flow<T> = StreamFlow(this)
1919
private class StreamFlow<T>(private val stream: Stream<T>) : Flow<T> {
2020
private val consumed = atomic(false)
2121

22-
@InternalCoroutinesApi
2322
override suspend fun collect(collector: FlowCollector<T>) {
2423
if (!consumed.compareAndSet(false, true)) error("Stream.consumeAsFlow can be collected only once")
2524
try {

kotlinx-coroutines-core/common/src/flow/Flow.kt

+1-3
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ import kotlin.coroutines.*
172172
*
173173
* **The `Flow` interface is not stable for inheritance in 3rd party libraries**, as new methods
174174
* might be added to this interface in the future, but is stable for use.
175-
* Use the `flow { ... }` builder function to create an implementation.
175+
* Use the `flow { ... }` builder function to create an implementation, or extend [AbstractFlow].
176176
*/
177177
public interface Flow<out T> {
178178
/**
@@ -184,7 +184,6 @@ public interface Flow<out T> {
184184
* should be used. Such limitation ensures that the context preservation property is not violated and prevents most
185185
* of the developer mistakes related to concurrency, inconsistent flow dispatchers and cancellation.
186186
*/
187-
@InternalCoroutinesApi
188187
public suspend fun collect(collector: FlowCollector<T>)
189188
}
190189

@@ -214,7 +213,6 @@ public interface Flow<out T> {
214213
@FlowPreview
215214
public abstract class AbstractFlow<T> : Flow<T>, CancellableFlow<T> {
216215

217-
@InternalCoroutinesApi
218216
public final override suspend fun collect(collector: FlowCollector<T>) {
219217
val safeCollector = SafeCollector(collector, coroutineContext)
220218
try {

kotlinx-coroutines-core/common/src/flow/SharedFlow.kt

-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ public interface SharedFlow<out T> : Flow<T> {
140140
*
141141
* @see [Flow.collect]
142142
*/
143-
@InternalCoroutinesApi
144143
override suspend fun collect(collector: FlowCollector<T>): Nothing
145144
}
146145

kotlinx-coroutines-core/common/src/flow/operators/Distinct.kt

-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ private class DistinctFlowImpl<T>(
7171
@JvmField val keySelector: (T) -> Any?,
7272
@JvmField val areEquivalent: (old: Any?, new: Any?) -> Boolean
7373
): Flow<T> {
74-
@InternalCoroutinesApi
7574
override suspend fun collect(collector: FlowCollector<T>) {
7675
var previousKey: Any? = NULL
7776
upstream.collect { value ->

0 commit comments

Comments
 (0)