tseisel
10/22/2019, 6:45 PMmap
operation in the following sample :
sealed class Request<T> {
object Pending : Request<Nothing>()
class Success<T>(val result: T) : Request<T>()
class Failure(val error: Throwable) : Request<Nothing>()
}
val sourceFlow: Flow<Foo> = getFooFlow()
sourceFlow.map { Request.Success(it) as Request<Foo> }
.onStart { emit(Request.Pending) }
.catch { emit(Request.Failure(it) }
.onEach { ... }
.launchIn(scope)
Will this kind of issue be fixed by the new Kotlin inference ?
Or is there a workaround (other than creating a typed temporary variable) ?Stephan Schroeder
10/23/2019, 9:18 AMsourceFlow.map { Request.Success(it) }
works fine for metseisel
10/23/2019, 12:28 PMonStart
, just like in the sample code ? This should trigger a compile error, as Request.Pending
is not a Request.Success
.Stephan Schroeder
10/23/2019, 12:50 PM