Just lost a couple of minutes for a strange issue ...
# coroutines
t
Just lost a couple of minutes for a strange issue with StateFlow. When using .collect {} it was automatically resolved to https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/common/src/flow/Flow.kt#L177 and did not propose the proper imports so obviously did not compile. Does anyone know why it resolved to that one without any related imports? (With 1.3.8) Manually adding the proper import fix the issue, but it's hard to figure out by default.
o
because a FlowCollector is a Single-Abstract-Method interface
so
.collect {}
is technically valid for it
t
Yes but why it's used without imports ? I would expect that it did not resolve and I had to import the proper one via alt+enter. Having default internal non usable thing used is weird.
o
because it's a method on flow? it's not an extension, it's always there
it's like asking "how do you use
Any.toString()
without importing it"
t
Well then having the extension name collision makes this strange to use, can't even use automatic IDE import resolution. Start by having an error then manual import does not sounds logical.
o
yes, I think it is a really weird design choice -- I don't recall why it is this way, and I thought there was a related issue for de-prioritzing it in completions, but I can't find it now
t
Oh nice it's fixed in 1.4 🙂 Thanks for the link.