Skip to content

FlowCollector fun interface errors due to collect being InternalCoroutinesApi #3078

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

Closed
Tolriq opened this issue Dec 10, 2021 · 4 comments · Fixed by efirestone/hassle#45
Closed

Comments

@Tolriq
Copy link

Tolriq commented Dec 10, 2021

As per the title the change in 1.6 RC2 breaks code that are copy pasted from Compose for example:

@Composable
fun <T : R, R> Flow<T>.collectAsState(
    initial: R,
    context: CoroutineContext = EmptyCoroutineContext
): State<R> = produceState(initial, this, context) {
    if (context == EmptyCoroutineContext) {
        collect { value = it }
    } else withContext(context) {
        collect { value = it }
    }
}

Will produce This is an internal kotlinx.coroutines API that should not be used from outside of kotlinx.coroutines. No compatibility guarantees are provided. It is recommended to report your use-case of internal API to kotlinx.coroutines issue tracker, so stable API could be provided instead

@ZacSweers
Copy link
Contributor

#3082 removes it from some implementation classes, but I don't see how that resolves this since those implementation classes are usually opaque to users. Most code is solely collecting from a Flow itself, which still only has an @InternalCoroutinesApi-annotated collect() function. Am I missing something? It seems like the extension function was the only way to collect in the public API.

@ZacSweers
Copy link
Contributor

Scratch that, I see it's merged into develop and not master. Apologies for the noise!

@bubenheimer
Copy link

Seems odd that this did not get caught by automated testing or even just building the tests, pre-release. Maybe add or change something to capture this kind of scenario?

@LouisCAD
Copy link
Contributor

I think the tests run with opt-in for the @InternalCoroutinesApi.

efirestone added a commit to efirestone/hassle that referenced this issue Dec 18, 2021
yorickhenning pushed a commit to yorickhenning/kotlinx.coroutines that referenced this issue Jan 28, 2022
* Get rid of @InternalCoroutinesApi from Flow.collect member

Fixes Kotlin#3078
pablobaxter pushed a commit to pablobaxter/kotlinx.coroutines that referenced this issue Sep 14, 2022
* Get rid of @InternalCoroutinesApi from Flow.collect member

Fixes Kotlin#3078
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants