<https://pl.kotl.in/lkskQc2rY> is there anything t...
# announcements
a
https://pl.kotl.in/lkskQc2rY is there anything the compiler could do to make this work?
Copy code
enum 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 issue
d
Why not change fooArray to take Array<out Foo>?
👍 2
a
Why not change fooArray to take Array<out Foo>?
Because
fooArray
is from a dependency I have. But I suggested that to the authors.
I'm just wondering if it even makes sense for the compiler to try to be "smart" in case of final classes.
d
Just write an extension function to convert the array
a
What I did was to just use
arrayOf(*foos)
and it does the job, so that's not a problem
👍 2