Kotlin-native: value classes?

So I’m having trouble finding an answer to this: the KEEP specifies that (emphasis mine):

Kotlin/Native can support value classes with multiple fields. Moreover, Kotlin/Native being based on LLVM, could be passing around and storing value objects with multiple underlying fields without boxing them with relative ease.

What is the current status of this? Are value classes generally supported in Kotlin/Native? Do they offer a performance benefit, e.g. an array of value class instances being totally contiguous in memory? Does @JvmInline mean anything in Kotlin/Native?

Thanks in advance.

AFAIK, value classes are inlined on all platforms currently. However, what the keep is referencing is multi-field value classes, which is similar to a struct. I believe there is internal compiler work to support those efficiently on K/N, but none of that is available to play with just yet. Rest assured though that, after K2 gets released, the compiler team will be focusing on those features with a lot more manpower

1 Like