Files
kotlin-fork/compiler/testData/codegen/box/reflection/annotations/hasAnnotation.kt
T
Kerooker a342f844b8 Implements KAnnotatedElement.hasAnnotation()
This commit fixes KT-29041, by adding a convenience method to verify if a certain `KAnnotatedElement` has an annotation or not
2019-03-08 14:53:51 +01:00

26 lines
452 B
Kotlin
Vendored

// TARGET_BACKEND: JVM
// WITH_REFLECT
import kotlin.reflect.full.hasAnnotation
import kotlin.test.assertFalse
import kotlin.test.assertTrue
annotation class Baz
annotation class Far
@Baz
@Far
class Foo
class Bar
fun box(): String {
assertFalse(Bar::class.hasAnnotation<Baz>())
assertFalse(Bar::class.hasAnnotation<Far>())
assertTrue(Foo::class.hasAnnotation<Baz>())
assertTrue(Foo::class.hasAnnotation<Far>())
return "OK"
}