Klitos Kyriacou
06/04/2025, 2:51 PMimport kotlin.reflect.full.hasAnnotation
annotation class Annotation1
annotation class Annotation2
@Annotation1
@Annotation2
annotation class CombinedAnnotation
@CombinedAnnotation class X
fun main() {
println(X::class.hasAnnotation<Annotation1>())
}
That above prints "false". My inspiration is from Spring, which annotates the @Service
annotation with @Component
and the doc says that the former is a specialization of the latter (so every class annotated with @Service
is treated as if it was also a @Component
).ephemient
06/04/2025, 3:21 PMephemient
06/04/2025, 3:22 PM