Zach Klippenstein (he/him) [MOD]
06/02/2020, 12:19 AMAny), when you pass a value that satisfies the bounds, the compiler suddenly can’t figure out which one to call.
So this works:
fun <T : Any> StateFlow<T>.thing(): Unit = TODO()
fun <T : Any> Flow<T>.thing(): Unit= TODO()
MutableStateFlow("").thing()
And this:
fun <T> StateFlow<T>.thing(): Unit = TODO()
fun <T> Flow<T>.thing(): Unit = TODO()
MutableStateFlow("").thing()
And this:
fun <T : Any> StateFlow<T>.thing(): Unit = TODO()
fun <T> Flow<T>.thing(): Unit= TODO()
MutableStateFlow("").thing()
But not this:
fun <T> StateFlow<T>.thing(): Unit = TODO()
fun <T : Any> Flow<T>.thing(): Unit = TODO()
MutableStateFlow("").thing()Zach Klippenstein (he/him) [MOD]
06/02/2020, 12:31 AMZach Klippenstein (he/him) [MOD]
06/02/2020, 1:04 AM(MutableStateFlow("") as StateFlow<String?>).thing()
This definitely seems like a compiler bug.mikhail.zarechenskiy
06/02/2020, 8:02 AMStateFlow<T1> subtype of Flow<T> where T1 is just some type with a supertype of Any? and T is a type variable with the upperbound of Any? If that were true, then the compiler would choose StateFlow<T>.thing() as it's receiver would be more specific (its type contains fewer values). But it's not true and the opposite: Flow<T1> is also not a subtype of StateFlow<T> => these functions are equally specificZach Klippenstein (he/him) [MOD]
06/02/2020, 2:44 PMmikhail.zarechenskiy
06/16/2020, 5:29 PM