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
@@ -23,4 +23,4 @@ package kotlin.reflect
@Deprecated("Use 'findAnnotation' from kotlin.reflect.full package", ReplaceWith("this.findAnnotation<T>()", "kotlin.reflect.full.findAnnotation"), level = DeprecationLevel.WARNING)
@Suppress("UNCHECKED_CAST")
inline fun <reified T : Annotation> KAnnotatedElement.findAnnotation(): T? =
annotations.first { it is T } as T
annotations.firstOrNull { it is T } as T?
@@ -24,4 +24,4 @@ import kotlin.reflect.*
*/
@Suppress("UNCHECKED_CAST")
inline fun <reified T : Annotation> KAnnotatedElement.findAnnotation(): T? =
annotations.first { it is T } as T
annotations.firstOrNull { it is T } as T?