baxter
05/07/2021, 4:51 PMcollect {}
without auto-importing it), it'll default to the Flow.collect()
method, which should be expected since the extension function collect {}
was not imported. The problem is that when you do this, there's no option to automatically fix the issue unless you manually add the import statement, or re-type in "collect" but allowing auto-import to do its job.
Now that I have seen this issue, I know how I can help my teammates next time, as we continue working with Coroutines/Flow. However, this was a minor point of frustration... So my question is: Is there any plan to rename or remove the Flow.collect
function so this doesn't happen again?
Screenshot is an example of how unhelpful lint is when you find yourself using Flow.collect()
by accidentrnett
05/07/2021, 9:52 PMbaxter
05/07/2021, 10:53 PMkotlinx.coroutines.flow.collect
, you would probably try to make use of the class function collect()
. Not to mention the JB IDE does a great job showing you that you are using an internal API, but just misses by not telling you how to fix it.ephemient
05/08/2021, 1:10 AMinterface Flow { fun collect() }
were annotated
@Deprecated(
message = "Use extension function instead",
replaceWith = ReplaceWith(
expression = "collect(collector)",
imports = ["kotlinx.coroutines.flow.collect"]
)
)
it would help external users, but be annoying to internal users. I wonder if there's some better middle path. may be worth filing a feature request forrnett
05/08/2021, 2:21 AMRequiresOptIn
annotation (InternalCoroutinesApi
?) once the "lower resolution priority" is implemented ([KTIJ-933](https://youtrack.jetbrains.com/issue/KTIJ-933)). Still would need something in the meantime though.baxter
05/08/2021, 3:48 PMcollect0
, which is obviously wrong for consumers of the library, but distinguishable for internal users.ephemient
05/08/2021, 4:16 PM