Add a proposal for "data objects"
The @hash part is meaningless even for non-ADT objects, because object is a singleton
On JVM, a data object is a singleton in each ClassLoader, so multiple objects with the same FQN (and maybe the same code) can coexist in the same process.
The hash part is useful to detect different instances of the "same singleton".
This kind of issue occurs when multiple ClassLoaders are used, ie OSGi.
I note that only for completeness, but I don't think that the Kotlin language should address this issue.
copy makes no sense because it’s a singleton. Or should it be generated and always return this?
the copy method should never return this
The
hashpart is useful to detect different instances of the "same singleton".
Wouldn't it be more natural to use the === operator for that?
kotlinOptions {
jvmTarget = '1.8'
languageVersion = '1.9' // data objects
}
kotlin.sourceSets.all {
it.languageSettings.enableLanguageFeature("DataObjects")
}