Fix KAnnotatedElement.findAnnotation when no annotation is found

#KT-15540 Fixed
This commit is contained in:
Alexander Udalov
2017-01-09 11:15:49 +03:00
parent f4200e02bc
commit 32d2faf3d1
4 changed files with 13 additions and 2 deletions
@@ -2,6 +2,7 @@
// WITH_REFLECT
import kotlin.reflect.findAnnotation
import kotlin.test.assertNull
annotation class Yes(val value: String)
annotation class No(val value: String)
@@ -10,6 +11,11 @@ annotation class No(val value: String)
@No("Fail")
class Foo
class Bar
fun box(): String {
assertNull(Bar::class.findAnnotation<Yes>())
assertNull(Bar::class.findAnnotation<No>())
return Foo::class.findAnnotation<Yes>()?.value ?: "Fail: no annotation"
}