I have extension function on Single class:
fun <T: Response<BaseResponse>> Single<T>.checkResponse(): Single<BaseResponse> {
return this.map { some code }
}
And trying to use it like:
fun sign(body: Map<String, String>): Single<SignResponse> {
return service.sign(body).checkResponse().map { it }
}
Service's sign signature:
@POST(Urls.SIGN)
fun sign(@Body body: Map<String, String>): Single<Response<SignResponse>>
SignResponse inherits BaseResponse obviously
Response is retrofit2.response
And I've got an error:
Type parameter bound for T in fun <T : Response<BaseResponse>> Single<T>.checkResponse(): Single<BaseResponse> is not satisfied: inferred type Response<SignResponse> is not a subtype of Response<BaseResponse>
How do I need to write extension function to tell compiler that Single have Response, which have type inherited from BaseResponse?