Is there a way of creating a custom annotation like data? I.e. having an annotation that generates some code and my own code can use, and (as bonus) that IDEA won’t mark as invalid?
If that’s not possible, does accessing Kotlin annotations at runtime have the same performance implications as with Java? (which uses reflection, which means it’s bad in places like Android)
Annotations are just standard JVM entities and doesn't differ much from those generated by Java compiler. As of now, there is no special facility to create custom code transformations or generators in the language. You can use annotation processing to generate some code based on annotations. Or you can write compiler plugin, which is hard and unsupported, but may be much more powerful.
Is there any planned support to create our own “compiler” annotations? If I understand it correctly, using that “kapt” tool won’t make IDEA pick anything that it generates because it needs a separate step.
Right now, it might be a bit overkill, but I’ve created a few annotations that I use to mark some classes and store metadata about them (things like “speed” or “altitude”). At runtime, I get the annotations using reflection and get those values. It will be nice if I can instead get the values using getters, like the data annotation does.
I can also obviously move all this annotation metadata to normal fields, but the definition of the metadata was very nice to read, at least in Java.
Well, that's more verbose than the annotations, but interesting nonetheless :). I'll read about those companion objects to see what they can do, thanks!