Hey, I don't seem to be able to get annotations fr...
# compiler
y
Hey, I don't seem to be able to get annotations from a local delegated property. Is that normal? here's what I'm doing (I'm using the full reflection and everything):
Copy code
operator fun Foo.provideDelegate(thisRef: Any?, prop: KProperty<*>): Bar {
  val annotations = prop.annotations // always empty
}
fun main() {
  @Baz
  val foo by Foo
}
@Retention(AnnotationRetention.RUNTIME)
annotation class Baz
object Foo
prop.annotations
always seems to be empty. I understand that there's something about retaining the annotations for local variables? But since this is a local property, I'd expect that you'd be able to preserve it somewhere in the Kotlin reflection info, no? Edit: digging deeper, seems that the property's protobuf has a
NonEmptyDeserializedAnnotations
that then returns an empty list for some reason. Very strang
Can
kotlin-metadata
somehow fix this? I'd be perfectly content using it if it can detect these local property annotations
Hmmm, I just did a diff on the generated classes of the same file, but with changing the amount of annotations on its local property, while keeping the same line count, column count, etc, and the files are identical! I assume that means those annotations are stored nowhere in the binary?
t
Don't know if it is related, but I've seen a similar problem with annotated function parameters. In this code the annotation is not present at the time the compiler calls the compiler plugins. The IR does not have any annotations for
b
. If it is not in IR, I guess it will be missing from the generated code as well.
Copy code
fun a(
   @Adaptive b : () -> Unit
)
u
It's a bug, please report at https://kotl.in/issue
y