evant
04/04/2021, 3:10 PMKSP now handles annotation use site targets internally for property accessors (namely,@get:Anno
).@set:Anno
property accessors will have corresponding targeted annotations from their receiver properties
annotations withI had this code to find a getter annotation on a constructor val and it's no longer finding itand@get:
targets will not appear in property's annotation list.@set:
class Foo(@get:Annotation val bar: String)
fun KSAnnotated.hasAnnotation(className: String, useSiteTarget: AnnotationUseSiteTarget? = null): Boolean {
return annotations.any {
it.annotationType.resolve().declaration.qualifiedName?.asString() == className &&
useSiteTarget == it.useSiteTarget
}
}
override fun hasAnnotation(className: String): Boolean {
return declaration.getter?.hasAnnotation(className) == true ||
declaration.hasAnnotation(className, AnnotationUseSiteTarget.GET)
}
yigit
04/04/2021, 4:09 PMevant
04/05/2021, 1:36 PM@get:Annotation
is moved to the getter but it still has a useSiteTarget of GET
.evant
04/05/2021, 1:39 PM