Dariusz Kuc
12/16/2020, 5:33 PMpublic fun <T : kotlin.Any> org.reactivestreams.Publisher<T>.asFlow(): kotlinx.coroutines.flow.Flow<T>
public fun <T : kotlin.Any> kotlinx.coroutines.flow.Flow<T>.asPublisher(): org.reactivestreams.Publisher<T>
This is valid
// inferred -> flow: Flow<Any?>?
val flow = when (val publisherOrFlow: Any? = fetchValue()) {
is Publisher<*> -> publisherOrFlow.asFlow()
is Flow<*> -> publisherOrFlow
else -> null
}
Yet this is invalid
// inferred -> publisher: Publisher<*>?
val publisher = when (val publisherOrFlow: Any? = fetchValue()) {
is Publisher<*> -> publisherOrFlow
is Flow<*> -> publisherOrFlow.asPublisher() // <-- issue here -> inferred type Any? is not a subtype of Any
else -> null
}
Dariusz Kuc
12/16/2020, 5:34 PMPublisher
is Java interface?Shane Myrick
12/16/2020, 7:03 PM.asPublisher
?Dariusz Kuc
12/16/2020, 7:33 PM