I have a few interfaces that looks something like the following:
interface ApiInterface : Context.Element {
@GET(Urls.url)
suspend fun getSomeData(): Data
}
interface Context.Element {
operator fun plus(context: Context): Context
}
I am trying to implement a Context implementation in similar way of the Kotlin CoroutineContext. As I am trying to add my Retrofit http interface as a Context.Element it ends up inheriting some other functions. The code compiles and runs fine until I call a function from my ApiInterface instance which inherits from Context.Element therefore doesn't have any @GET, @POST or any retrofit annotation.
If I run the following code:
val context = ApiInterfaceImpl()
context + DifferentApiInterfaceImpl()
I receive a Exception in thread "main" java.lang.IllegalArgumentException: HTTP method annotation is required (e.g., @GET, @POST, etc.). for method Context.plus.
I believe that if I am able to make the Retrofit annotation processor to skip the functions inherited from Context.Element this problem would be solved. Is there any way to to this? Any @Transient like annotation for functions? I tried to use @JvmSynthetic but no luck.