Files
kotlin-fork/compiler/testData/diagnostics/tests/collectionLiterals/collectionLiteralsWithVarargs.fir.kt
T
Kirill Rakhman 97024d9ccb [FIR] Resolve array literal argument for non-primitive-array parameter as arrayOf call in annotation calls
This allows us to properly complete array literals arguments of
annotation calls fixing several false-negative type mismatch errors
as well as enabling the inference of generic type arguments.

#KT-59581 Fixed
#KT-58883 Fixed
2023-07-19 13:34:58 +00:00

41 lines
996 B
Kotlin
Vendored

// !LANGUAGE: +ProhibitAssigningSingleElementsToVarargsInNamedForm
annotation class Ann1(vararg val a: String = [])
annotation class Ann2(vararg val a: Int = [1, 2])
annotation class Ann3(vararg val a: Float = [1f])
annotation class Ann4(vararg val a: String = ["/"])
annotation class Ann5(vararg val a: Ann4 = [])
annotation class Ann6(vararg val a: Ann4 = [Ann4(*["a", "b"])])
annotation class Ann7(vararg val a: Long = <!INITIALIZER_TYPE_MISMATCH!>[1L, null, ""]<!>)
@Ann1(*[])
fun test1_0() {}
@Ann1(*["a", "b"])
fun test1_1() {}
@Ann1(*<!ARGUMENT_TYPE_MISMATCH!>["a", 1, null]<!>)
fun test1_2() {}
@Ann2(*[])
fun test2() {}
@Ann3(a = *<!REDUNDANT_SPREAD_OPERATOR_IN_NAMED_FORM_IN_ANNOTATION!>[0f, <!DIVISION_BY_ZERO!>1 / 0f<!>]<!>)
fun test3() {}
@Ann5(Ann4(*["/"]))
fun test5() {}
@Ann6(*[])
fun test6() {}
annotation class AnnArray(val a: Array<String>)
@AnnArray(<!NON_VARARG_SPREAD!>*<!>["/"])
fun testArray() {}
@Ann1(<!ARGUMENT_TYPE_MISMATCH!>[""]<!>)
fun testVararg() {}