mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-17 00:21:28 +00:00
Fixes #KT-23153 for Kotlin 1.3 The problem was in the type check of expression type against expected type. When feature `AssigningArraysToVarargsInNamedFormInAnnotations` (KT-20171) appeared, expected type could be wrong, which led to failed type check
27 lines
866 B
Kotlin
Vendored
27 lines
866 B
Kotlin
Vendored
// !LANGUAGE: -ProhibitNonConstValuesAsVarargsInAnnotations
|
|
|
|
val nonConstArray = longArrayOf(0)
|
|
fun nonConstFun(): LongArray = TODO()
|
|
|
|
fun nonConstLong(): Long = TODO()
|
|
|
|
annotation class Anno(vararg val value: Long)
|
|
|
|
@Anno(value = <!ANNOTATION_ARGUMENT_IS_NON_CONST!>nonConstArray<!>)
|
|
fun foo1() {}
|
|
|
|
@Anno(value = <!ANNOTATION_ARGUMENT_IS_NON_CONST!>nonConstFun()<!>)
|
|
fun foo2() {}
|
|
|
|
@Anno(value = <!ANNOTATION_ARGUMENT_IS_NON_CONST!>longArrayOf(<!ANNOTATION_ARGUMENT_IS_NON_CONST!>nonConstLong()<!>)<!>)
|
|
fun foo3() {}
|
|
|
|
@Anno(value = <!ANNOTATION_ARGUMENT_IS_NON_CONST!>[<!ANNOTATION_ARGUMENT_IS_NON_CONST!>nonConstLong()<!>]<!>)
|
|
fun foo4() {}
|
|
|
|
@Anno(value = *<!ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_ANNOTATION, ANNOTATION_ARGUMENT_MUST_BE_CONST!>nonConstArray<!>)
|
|
fun bar1() {}
|
|
|
|
@Anno(*<!ANNOTATION_ARGUMENT_MUST_BE_CONST!>nonConstArray<!>)
|
|
fun bar2() {}
|