Slight Problem with Varargs


Say I have a generic class in Kotlin that is contravariant:

  class A<in T>

And a function/method has a varargs parameter of that type:

  fun afunc(varargs args: A<T>) …

When I use that function in Java code (I haven’t checked in Kotlin code yet), I get a compiler error when I try to use A objects where the generic is a superclass of T. To fix it, I actually explicitly tell the varargs to be contravariant:

  fun afunc(varargs args: A<in T>) …

And now the code works in Java, but I’m getting a warning from the Kotlin compiler that this is redundant (which I agree that it should be), but removing it causes errors. Something doesn’t seem to be quite right with the translation over to varargs when it comes to generics. The compiler knows that it shouldn’t be necessary to use the use-sight label, but it is necessary.


It's a bug. Please report to the tracker:


THAT'S where you report bugs. This was the closest I could find. I had expected to find it on github, but it wasn't there. Thanks for the link.


It's the fifth link from the top in on GitHub. It's also linked from the index page of We're not hiding it.


My bad. I skipped right over those links looking for a header about submitting issues.