Files
kotlin-fork/compiler/testData/diagnostics/tests/varargs/kt48162.fir.kt
T
Victor Petukhov d9c50f0fda Report NON_VARARG_SPREAD on missed cases
^KT-48162 Fixed
2021-09-30 20:08:56 +03:00

23 lines
683 B
Kotlin
Vendored

// !DIAGNOSTICS: -UNCHECKED_CAST
fun <T> Collection<T>.toArray(): Array<T> = this as Array<T>
fun Collection<String>.toArray2(): Array<String> = this as Array<String>
fun <T> toArray3(x: Collection<T>): Array<T> = x as Array<T>
class Foo<T> {
operator fun plus(x: Foo<T>): Array<T> {
return this + x
}
}
fun use(arg: Array<String>, s: Collection<String>, x: Foo<String>) {
arr(<!NON_VARARG_SPREAD!>*<!>arg)
arr(<!NON_VARARG_SPREAD!>*<!>s.toArray())
arr(<!NON_VARARG_SPREAD!>*<!>s.toArray2())
arr(<!NON_VARARG_SPREAD!>*<!>toArray3(s))
arr(<!NON_VARARG_SPREAD!>*<!>x + x)
arr(<!NON_VARARG_SPREAD!>*<!>(x + x))
}
fun arr(x: Array<String>) {}