smcvb
02/08/2017, 1:47 PMElementType.TYPE
and ElementType.FIELD
on the field in a Kotlin interface.
My annotation is set up like this in java:
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.FIELD})
public @interface MyAnnoation {
}
To only put @MyAnnotation
on the field within the interface and not on get/set functions, I thus use the annotation use-site target (as described in https://kotlinlang.org/docs/reference/annotations.html) to set the annotation like this:
interface SomeInterface {
@field:MyAnnotation val fieldX: TypeX
val fieldY: TypeY
}
thinking this should work.
I however still get the compile exception: Error:(18, 5) Kotlin: This annotation is not applicable to target 'member property without backing field or delegate' and use site target '@field'
What's your guess, am I doing something wrong in my annotation or something in the way I try to set the annotation in the interface?