Annotation typealias

Arguments to annotations have to be compile-time constants, so it seems to me some syntax like this could exist:

typealias MySpecificAnnotation = SomeAnnotation("argument")

Now, it’s possible something like this already exists that I missed, and it’s also possible I’ve neglected to consider some reasons why something like this would be inadviseable, but I was curious if it was considered.

3 Likes

I’d also like to see something like typealias MyAnnotation(x: String) = OtherAnnotation(x, CONSTANT) or even typealias MyAnnotation = OtherAnnotation() + AnotherAnnotation() (adding two annotations with a single annotation, I’ve seen classes where every field has three annotations for various serialization frameworks, and they all take the same argument).

4 Likes

Yes please, the ability to create a custom @PublicApi annotation that suppresses unused warnings, and does a few other things would be incredibly useful for library authors