Take the definition of copyOf
:
fun <T> Array<T>.copyOf(newSize: Int): Array<T?>
Why can it be called with a contravariant parameter (Array<in Number>
), but not with a covariant parameter (Array<out Number>
)?
The first will return Array<in Number?>
whereas the second will issue Unsupported [Array<Nothing> in return type is illegal]