KT-14196 Do not allow class literal with expression in annotation arguments
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
// WITH_REFLECT
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
annotation class Ann(val k: KClass<*>)
|
||||
annotation class AnnArray(val kk: Array<KClass<*>>)
|
||||
|
||||
object AnObject
|
||||
|
||||
class C {
|
||||
companion object
|
||||
}
|
||||
|
||||
fun foo() = "foo"
|
||||
|
||||
@Ann(<!ANNOTATION_PARAMETER_MUST_BE_KCLASS_LITERAL!>"foo"::class<!>)
|
||||
fun test1() {}
|
||||
|
||||
@Ann(String::class)
|
||||
fun test2() {}
|
||||
|
||||
@Ann(AnObject::class)
|
||||
fun test4() {}
|
||||
|
||||
@Ann(C::class)
|
||||
fun test5() {}
|
||||
|
||||
@Ann(C.Companion::class)
|
||||
fun test6() {}
|
||||
|
||||
@Ann(<!ANNOTATION_PARAMETER_MUST_BE_KCLASS_LITERAL!>foo()::class<!>)
|
||||
fun test7() {}
|
||||
|
||||
@AnnArray(arrayOf(<!ANNOTATION_PARAMETER_MUST_BE_KCLASS_LITERAL!>""::class<!>, String::class, AnObject::class))
|
||||
fun test8() {}
|
||||
Reference in New Issue
Block a user