Skip to content

Commit

Permalink
Do not mark AbstractFlow as brittle for inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
dkhalanskyjb committed May 22, 2024
1 parent 4aaf79d commit f0f1c2a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
1 change: 0 additions & 1 deletion kotlinx-coroutines-core/common/src/flow/Builders.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ import kotlinx.coroutines.flow.internal.unsafeFlow as flow
public fun <T> flow(@BuilderInference block: suspend FlowCollector<T>.() -> Unit): Flow<T> = SafeFlow(block)

// Named anonymous object
@OptIn(BrittleForInheritanceCoroutinesApi::class)
private class SafeFlow<T>(private val block: suspend FlowCollector<T>.() -> Unit) : AbstractFlow<T>() {
override suspend fun collectSafely(collector: FlowCollector<T>) {
collector.block()
Expand Down
3 changes: 1 addition & 2 deletions kotlinx-coroutines-core/common/src/flow/Flow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,8 @@ public interface Flow<out T> {
* }
* ```
*/
@OptIn(ExperimentalSubclassOptIn::class)
@ExperimentalCoroutinesApi
@SubclassOptInRequired(BrittleForInheritanceCoroutinesApi::class)
@OptIn(BrittleForInheritanceCoroutinesApi::class)
public abstract class AbstractFlow<T> : Flow<T>, CancellableFlow<T> {

public final override suspend fun collect(collector: FlowCollector<T>) {
Expand Down

0 comments on commit f0f1c2a

Please sign in to comment.