I have a class `A` that's part of a library that I...
# flow
j
I have a class
A
that's part of a library that I'm writing that is getting pulled into a sample app through Gradle. `A`'s constructor contains parameter of type
SharedFlow<C>
where
C
is a subclass of
B
When I import the library in my Android app, I see in the decompiled code that the parameter is listed as type
SharedFlow<out B>
. The compiler is complaining that it is looking for
SharedFlow<B>
but I'm providing
SharedFlow<C>
. While I loosely understand generics, I don't understand what is happening here. Can anyone explain?
k
Two thoughts: 1. You might have a better chance of getting help on this using a different channel, given this doesn’t really come down to a question about Kotlin Flow 2. Sharing some code may help people understand the situation you’re in and better be able to help you
j
Thanks Kevin. I've identified the root cause, my project was managing transitive dependencies improperly. As you noted, I unfortunately did not post enough info here to be able to resolve the issue. I will post more carefully in the future. My hope was that this was a typical error when working with flow parameters, but that turned out not to be the issue. On a side note, in reading through old posts, it seems clear that I should be passing as a
Flow
and not a
SharedFlow
unless I need to use the replay cache based on this conversation: https://kotlinlang.slack.com/archives/CRJCTR5PD/p1625556094048000?thread_ts=1625493055.046500&amp;cid=CRJCTR5PD