我有一些类似于以下内容的界面:
interface ApiInterface : Context.Element {
@GET(Urls.url)
suspend fun getSomeData(): Data
}
interface Context.Element {
operator fun plus(context: Context): Context
}
我正在尝试以Context
类似Kotlin的 方式实施实现CoroutineContext
。当我尝试添加Retrofit http接口时,Context.Element
它最终继承了一些其他功能。该代码编译并运行正常,直到我把从我ApiInterface实例功能,从继承Context.Element
,因此没有任何@GET
,@POST
或任何改装的注释。
如果我运行以下代码:
val context = ApiInterfaceImpl()
context + DifferentApiInterfaceImpl()
我收到了Exception in thread "main" java.lang.IllegalArgumentException: HTTP method annotation is required (e.g., @GET, @POST, etc.). for method Context.plus
。
我相信,如果我能够使Retrofit批注处理器跳过从此Context.Element
问题继承的功能,将会得到解决。有什么办法吗?任何@Transient
类似的功能注释?我尝试使用@JvmSynthetic
但没有运气。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句