Status of Annotations on typealias - supported?



The original KEEP for typealias suggests that annotations on typealias will be supported:

Q: Are annotations on type alias declarations going to be supported?
A: Yes. Just like annotations on properties, they’ll be stored on synthetic methods in JVM binaries.

This doesn’t appear to be working yet – is this on the roadmap in any upcoming release?



Annotations on type aliases should be already supported.

Could you show the particular case where they do not work?


That’s great news – thanks!!

I’m unclear how to access them.

In the given example:

typealias FirstName = String
typealias LastName = String

annotation class DataAttribute(val value:String)

data class Person(val firstName: FirstName, val lastName: LastName)

How are the annotations associated with FirstName and LastName accessed via reflection?


Unfortunately, there’s no API currently to get annotations from a typealias declaration in kotlin-reflect. I’ve reported an issue: