Traits and modifications of Kotlin

I am trying to implement an example from here in Kotlin. I get this error at runtime "Caused by: java.lang.IllegalArgumentException: interface definitions should not extend other interfaces". Is there a way to treat Kotlin features as java interfaces when they don't have any methods, or do I need to use java interfaces? Here is the code:

public trait RestAPI { [GET("/weather")] fun getList([Query("q")] place: String, [Query("units")] units: String) : Observable<WeatherData> } 

And the call causing the error:

 val service = restAdapter?.create(javaClass<RestAPI>()) 
+5
source share
1 answer

This issue has been fixed. I use Retrofit, implemented in exactly this way with Kotlin version 0.9.976.

+7
source

Source: https://habr.com/ru/post/1201756/


All Articles