Given the following sealed class hierarchy: ```sea...
# announcements
t
Given the following sealed class hierarchy:
Copy code
sealed class LoadRequest<out T> {
  object Pending : LoadRequest<Nothing>()
  class Success<T>(val data: T) : LoadRequest<T>()
  class Failure(val error: Throwable) : LoadRequest<Nothing>()
}
When writing the following code with Kotlin 1.4, I have a warning telling me that the following cast is unnecessary:
Copy code
val someFlow: Flow<String> = ...
val requestFlow: Flow<LoadRequest<String>> = someFlow
  .map { LoadRequest.Success(it) as LoadRequest<String> }
                                 ^^^^^^^^^^^^^^^^^^^^^^
  .onStart { emit(LoadRequest.Pending) }
  .catch { emit(LoadRequest.Failure(it) }
But removing it makes
onStart
and
catch
incompatible with the type of the returned
Flow
. Is this some new compiler inference bug ?