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.