Error: private constructors in Java and object expressions


I updated my Kotlin code for Square Retrofit 2.0.0-SNAPSHOT ( and the compiler (Kotlin 0.12.613) started to complain.

Here is my attempt to reproduce this issue completely in Kotlin (

data class Model

class Response<T> {

  private constructor() {}


interface Callback<T> {

  fun onResponse(response: Response<T>)

  fun onFailure(failure: Throwable)


fun main(args: Array<String>) {

  val callback = object : Callback<Model> {

  override fun onResponse(response: Response<Model>) {}

  override fun onFailure(failure: Throwable) {}



This unfortunately did not reproduce the error, but might provide an insight about the problem. If I replace my Response in Kotlin with the Response class in Java ( the compiler will output following error message:

'Response' is not an annotation class. Cannot access '<init>': it is 'private' in 'Response'. No value passed for parameter body. No value passed for parameter errorBody. No value passed for parameter rawResponse. A type annotation is required on a value parameter.


Oups, I'm so used to the "<type> <variable>" syntax of Java. I converted my code to "<variable>: <type>" and everything worked fine.

But here is a question: Does Kotlin always add an extends-wildcard to generics?

Retrofit uses some reflection to build REST APIs. It complains with:

Exception in thread "main" java.lang.IllegalArgumentException: Method return type must not include a type variable or wildcard: retrofit.Call<java.util.List<? extends retrofit.Repo>>

I’ve defined my interface with

interface GitHubService {
    fun listRepos(@Path("user") user: String,
                  @Query("page") page: Int): Call<List<Repo>>


This was solved by replacing List with MutableList as suggested in