[FIR] Report UNSUPPORTED on array literals not from annotation classes ^KT-50750 Fixed

This commit is contained in:
Ivan Kochurkin
2022-02-09 17:14:23 +03:00
committed by teamcity
parent 19285d0569
commit 73b45a1254
12 changed files with 139 additions and 94 deletions
@@ -0,0 +1,18 @@
annotation class AnnE(val i: String)
enum class MyEnum {
A
}
@AnnE(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!>"1" + MyEnum.A<!>)
class Test
@AnnE(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!>"1" + MyEnum::class<!>)
class Test2
@AnnE(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!>"1" + AnnE("23")<!>)
class Test3
@AnnE(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!>"1" + <!UNSUPPORTED!>arrayOf("23", "34")<!><!>)
class Test4
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
annotation class AnnE(val i: String)
enum class MyEnum {
@@ -1,48 +0,0 @@
// LANGUAGE: +ProhibitArrayLiteralsInCompanionOfAnnotation
// ISSUE: KT-39041
annotation class Ann(val x: IntArray = [1, 2, 3]) { // OK
companion object {
val y1: IntArray = [1, 2, 3] // Error
val z1: IntArray
get() = [1, 2, 3] // Error
fun test_1(): IntArray {
return [1, 2, 3] // Error
}
class Nested {
val y2: IntArray = [1, 2, 3] // Error
val z2: IntArray
get() = [1, 2, 3] // Error
fun test_2(): IntArray {
return [1, 2, 3] // Error
}
}
}
object Foo {
val y3: IntArray = [1, 2, 3] // Error
val z3: IntArray
get() = [1, 2, 3] // Error
fun test_3(): IntArray {
return [1, 2, 3] // Error
}
}
class Nested {
val y4: IntArray = [1, 2, 3] // Error
val z4: IntArray
get() = [1, 2, 3] // Error
fun test_4(): IntArray {
return [1, 2, 3] // Error
}
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// LANGUAGE: +ProhibitArrayLiteralsInCompanionOfAnnotation
// ISSUE: KT-39041
@@ -3,46 +3,46 @@
annotation class Ann(val x: IntArray = [1, 2, 3]) { // OK
companion object {
val y1: IntArray = [1, 2, 3] // Error
val y1: IntArray = <!UNSUPPORTED!>[1, 2, 3]<!> // Error
val z1: IntArray
get() = [1, 2, 3] // Error
get() = <!UNSUPPORTED!>[1, 2, 3]<!> // Error
fun test_1(): IntArray {
return [1, 2, 3] // Error
return <!UNSUPPORTED!>[1, 2, 3]<!> // Error
}
class Nested {
val y2: IntArray = [1, 2, 3] // Error
val y2: IntArray = <!UNSUPPORTED!>[1, 2, 3]<!> // Error
val z2: IntArray
get() = [1, 2, 3] // Error
get() = <!UNSUPPORTED!>[1, 2, 3]<!> // Error
fun test_2(): IntArray {
return [1, 2, 3] // Error
return <!UNSUPPORTED!>[1, 2, 3]<!> // Error
}
}
}
object Foo {
val y3: IntArray = [1, 2, 3] // Error
val y3: IntArray = <!UNSUPPORTED!>[1, 2, 3]<!> // Error
val z3: IntArray
get() = [1, 2, 3] // Error
get() = <!UNSUPPORTED!>[1, 2, 3]<!> // Error
fun test_3(): IntArray {
return [1, 2, 3] // Error
return <!UNSUPPORTED!>[1, 2, 3]<!> // Error
}
}
class Nested {
val y4: IntArray = [1, 2, 3] // Error
val y4: IntArray = <!UNSUPPORTED!>[1, 2, 3]<!> // Error
val z4: IntArray
get() = [1, 2, 3] // Error
get() = <!UNSUPPORTED!>[1, 2, 3]<!> // Error
fun test_4(): IntArray {
return [1, 2, 3] // Error
return <!UNSUPPORTED!>[1, 2, 3]<!> // Error
}
}
}
}