您好,我正在为Kotlin中的Retrofit API调用开发通用接口。我是Kotlin的新手,我觉得自己缺少重要的东西。我试图寻找一种解决方案,但没有找到。
这是我的界面
@JvmSuppressWildcards
interface GenericApiRequest {
@POST("/stuff")
suspend fun <TIn, TOut>getResponse(@Body request: TIn) : TOut
}
这是我使用的代码
val response = client.getResponse<RequestDataClass, ResponseDataClass>(RequestDataClass("stuff"))
这是我得到的错误:
Parameter type must not include a type variable or wildcard: TIn (parameter #1)
for method GenericApiRequest.getResponse
我认为可以通过@JvmSuppressWildcards解决,但没有帮助。有人对此有解决方案吗?