Fix KAnnotatedElement.findAnnotation when no annotation is found
#KT-15540 Fixed
This commit is contained in:
@@ -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"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user