Hi
Given the following code:
@Target(AnnotationTarget.FIELD, AnnotationTarget.PROPERTY)
annotation class SomeAnnotation
data class Thing(@SomeAnnotation val foo:String)
If I reflect, the annotation is discovered on the member.
However, if I add an annotation target of VALUE_PARAMETER, the annotation is no longer discoverable on the field, and has moved to the constructor param.
@Target(AnnotationTarget.FIELD, AnnotationTarget.PROPERTY, AnnotationTarget.VALUE_PARAMETER)
annotation class SomeAnnotation
data class Thing(@SomeAnnotation val foo:String)
This feels “surprising”, as to me, as it reads as though the annotation is now present in both locations - the constructor arg and the member. However, the compiler removes it from the member, to place it only on the constructor.
I’m interested in understanding the rationale for the behaviour, and also if it’s possible to change so that the annotation is made present in both.