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