[FIR] Allow annotation instantiation.
This commit disables the frontend error reporting for supported cases.
This commit is contained in:
committed by
TeamCityServer
parent
56d472451c
commit
b79ca7d7df
-18
@@ -1,18 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
// SKIP_TXT
|
||||
// !LANGUAGE: +InstantiationOfAnnotationClasses
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
annotation class A
|
||||
annotation class B(val int: Int)
|
||||
annotation class C(val int: Int = 42)
|
||||
|
||||
annotation class G<T: Any>(val int: KClass<T>)
|
||||
|
||||
fun box() {
|
||||
val a = <!ANNOTATION_CLASS_CONSTRUCTOR_CALL!>A()<!>
|
||||
val b = <!ANNOTATION_CLASS_CONSTRUCTOR_CALL!>B(4)<!>
|
||||
val c = <!ANNOTATION_CLASS_CONSTRUCTOR_CALL!>C()<!>
|
||||
val foo = <!ANNOTATION_CLASS_CONSTRUCTOR_CALL!>G(Int::class)<!>
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// WITH_RUNTIME
|
||||
// SKIP_TXT
|
||||
// !LANGUAGE: +InstantiationOfAnnotationClasses
|
||||
|
||||
+2
-2
@@ -7,8 +7,8 @@ val test1a = <!CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS!>AbstractClass()<!>
|
||||
|
||||
annotation class AnnotationClass
|
||||
typealias Test2 = AnnotationClass
|
||||
val test2 = <!ANNOTATION_CLASS_CONSTRUCTOR_CALL!>Test2()<!>
|
||||
val test2a = <!ANNOTATION_CLASS_CONSTRUCTOR_CALL!>AnnotationClass()<!>
|
||||
val test2 = Test2()
|
||||
val test2a = AnnotationClass()
|
||||
|
||||
enum class EnumClass { VALUE1, VALUE2 }
|
||||
typealias Test3 = EnumClass
|
||||
|
||||
+1
-1
@@ -21,4 +21,4 @@ annotation class AnnAnn(val i: Array<Ann>)
|
||||
@AnnAnn(arrayOf(Ann(intArrayOf(1))))
|
||||
@AnnAnn(<!NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION!>arrayOf(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!>iAnn<!>)<!>)
|
||||
class TestAnn
|
||||
val iAnn = <!ANNOTATION_CLASS_CONSTRUCTOR_CALL!>Ann(intArrayOf(1))<!>
|
||||
val iAnn = Ann(intArrayOf(1))
|
||||
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@Repeatable
|
||||
annotation class Ann(vararg val i: Int)
|
||||
|
||||
@Ann(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!>i<!>)
|
||||
@Ann(i2)
|
||||
@Ann(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!>i3<!>)
|
||||
@Ann(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!>i<!>, i2, <!ANNOTATION_ARGUMENT_MUST_BE_CONST!>i3<!>)
|
||||
@Ann(*<!NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION!>intArrayOf(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!>i<!>)<!>)
|
||||
@Ann(*intArrayOf(i2))
|
||||
@Ann(*<!NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION!>intArrayOf(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!>i3<!>)<!>)
|
||||
@Ann(*<!NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION!>intArrayOf(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!>i<!>, i2, <!ANNOTATION_ARGUMENT_MUST_BE_CONST!>i3<!>)<!>)
|
||||
class Test
|
||||
|
||||
var i = 1
|
||||
const val i2 = 1
|
||||
val i3 = foo()
|
||||
|
||||
fun foo(): Int = 1
|
||||
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@Repeatable
|
||||
annotation class AnnAnn(vararg val i: Ann)
|
||||
@AnnAnn(*arrayOf(Ann(1)))
|
||||
@AnnAnn(*<!NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION!>arrayOf(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!>iAnn<!>)<!>)
|
||||
class TestAnn
|
||||
val iAnn = <!ANNOTATION_CLASS_CONSTRUCTOR_CALL!>Ann(1)<!>
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@Repeatable
|
||||
annotation class Ann(vararg val i: Int)
|
||||
|
||||
Reference in New Issue
Block a user