I was testing Kotlin annotations and wasn't able to get this seemingly simple code to work
This is my simple annotation
@IntDef(1,2)
@Target(
AnnotationTarget.VALUE_PARAMETER)
@Retention(AnnotationRetention.SOURCE)
@MustBeDocumented
annotation class OnlyOneTwo
Now I am assuming that if I decorate a value parameter with @OnlyOneTwo , that method would raise a compile error if I give it a value like 5 .
I am using this annotation like this
fun onlyTakesOneTwos(@OnlyOneTwo input:Int){
}
onlyTakesOneTwos(6) // shouldn't this throw a compile error ?
I remember in Java it used to throw an error.