Type parameter output is declared as 'out' but occurs in 'invariant' position in type Flow<PagingData<output>>
abstract class PaginatedFlowUseCase<in Input, out output>(
private val dispatcher: CoroutineDispatcher
) {
operator fun invoke(input: Input): Flow<PagingData<output>> {
return execute(input).flowOn(dispatcher)
}
protected abstract fun execute(input: Input): Flow<PagingData<output>>
}
But it works when changing PagingData to kolin.Result class
y
Youssef Shoaib [MOD]
11/07/2022, 5:54 AM
It's likely that
PagingData
is declared with an invariant type parameter. You can either make
output
invariant by removing
out
, or you can replace
Flow<PagingData<output>>
with
Flow<PagingData<out output>>
. Also, please use PascalCase for your type parameters, it's the usual convention, so
Output
instead of
output
.
m
Muhammad Usman
11/07/2022, 5:58 AM
Copy code
abstract class PaginatedFlowUseCase<in Input, Output>(
private val dispatcher: CoroutineDispatcher
) {
operator fun invoke(input: Input): Flow<PagingData<Output>> {
return execute(input).flowOn(dispatcher)
}
protected abstract fun execute(input: Input): Flow<PagingData<Output>>
}
Type argument is not within its bound
Expected: Any
Found: Output
s
Stephan Schroeder
11/07/2022, 8:18 AM
i'm 80% sure that the issue is, that you didn't limit
Output
to extend from nonnullable
Any
(right now it's
Any?
by default). Try
abstract class PaginatedFlowUseCase<in Input, Output: Any>