Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kotlin traits and retrofit

I'm trying to implement the example from here in Kotlin. I get this error at runtime "Caused by: java.lang.IllegalArgumentException: Interface definitions must not extend other interfaces". Is there any way to treat Kotlin traits as java interfaces when they don't have any methods implemented, or do I have to use java interfaces? Here's the code:

public trait RestAPI {

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

And the call that causes the error:

val service = restAdapter?.create(javaClass<RestAPI>())
like image 226
user1202036 Avatar asked Sep 03 '14 17:09

user1202036


1 Answers

This issue has been fixed. I am using Retrofit implemented exactly this way with Kotlin version 0.9.976.

like image 53
Damian Petla Avatar answered Nov 15 '22 09:11

Damian Petla