KT-14196 Do not allow class literal with expression in annotation arguments

This commit is contained in:
Dmitry Petrov
2016-11-25 15:46:44 +03:00
parent 904ea33291
commit 5d1b848658
4 changed files with 100 additions and 1 deletions
@@ -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() {}