https://kotlinlang.org logo
#flow
Title
# flow
j

Justin Tarnoff

03/04/2023, 3:15 AM
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

Kevin Worth

03/06/2023, 4:08 PM
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

Justin Tarnoff

03/06/2023, 4:19 PM
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
6 Views