arekolek
04/06/2020, 10:33 AMenum class Foo {
ONE, TWO
}
fun fooArray(foos: Array<Foo>) {
println(foos.toList())
}
fun fooVararg(vararg foos: Foo) {
fooArray(foos) // Type mismatch: inferred type is Array<out Foo> but Array<Foo> was expected
}
in case of final classes (including enums), it's weird that vararg
should make the Array
have out
variance
I'm wondering if there's any sense in filing a youtrack issueDavid Eriksson
04/06/2020, 10:46 AMarekolek
04/06/2020, 11:42 AMWhy not change fooArray to take Array<out Foo>?Because
fooArray
is from a dependency I have. But I suggested that to the authors.David Eriksson
04/06/2020, 11:57 AMarekolek
04/06/2020, 1:38 PMarrayOf(*foos)
and it does the job, so that's not a problem