Repository navigation
inline value class: a uniform spelling for value classes of the inline kind for all platforms
#501
Replies: 5 comments 2 replies
|
|
I'm not convinced. First,
It's the exact same migration as migrating from But more importantly, the same KEEP states:
It sounds to me that this is behavior that is here to stay, and a meaningful semantic difference. Unless you have plans for these three use-cases to not need |
|
Hi mates! After internal discussions and taking your feedback into consideration, we will be going with the |
|
I am personally in favor of deprecating I don't particularly like that the annotation is called |
|
I assume that when Valhalla arrives, many code authors will like to use Valhalla value classes on the JVM (for Java compatibility, value-class arrays, etc.) and Kotlin inline value classes as a fallback solution on other platforms (for performance).
Can you describe if and how the new proposal supports this use-case. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Kotlin currently infers that single-field value classes are inline on non-JVM platforms implicitly, by the single-field shape, while JVM requires an explicit
@JvmInlineannotation. With full value classes (MFVCs), the implicit inference on non-JVM platforms becomes ambiguous:Adding a field could silently turn an inline value class into a full value class and change, for example, its serialized representation:
KEEP-0468 introduces
inline value classas a new unified spelling for this class kind while retaining@JvmInlineas an equivalent spelling. After migration, when full value classes are enabled, marked classes remain inline, while an unmarked value class denotes a full value class, even if it has a single field.We’d appreciate feedback on this idea, and the migration strategy, especially from multiplatform library and tooling authors.
All reactions