Disable componentN() generation in data classes

The fact that Kotlin generates componentN() methods in regards to the data in a data class doesn’t imply they’re not implementation artifacts. Indeed, I think they are. They are generated in order to compile Kotlin for the JVM, but they wouldn’t be required if the JVM directly supported data classes. Also, Kotlin compiler doesn’t allow to call componentN() methods from within Kotlin code, because they’re only needed to destructure objects. And since Java has never supported object destructuring (though I’ve heard of an upcoming version that may eventually support it), I think it’s just not needed to access data based on their indices, when fields can be accessed by name. Therefore, componentN() methods only serve as an implementation of the Kotlin destructuring feature, hence they’re artifacts. They’re just ugly and unuseful to be directly accessed using any JVM programming language, and so they should be annotated as @JvmSynthetic, as I think the Synthetic JVM attribute was meant for.

2 Likes