how can I use `value class` in a multiplatform pro...
# multiplatform
p
how can I use
value class
in a multiplatform project? Previously I used
inline class
but I see it’s deprecated now. Using
value class
produces an error “Value classes without @JvmInline annotation are not supported yet” and I cannot use
@JvmInline
in a multiplatform project obviously. What’s the recommended path forward? Keep using
inline class
? What’s the plan of proper multiplatform support for
value class
? Once we clarify all of it, I’ll propose some changes to the docs: https://kotlinlang.org/docs/inline-classes.html
1
h
You can use @JvmInline in multiplatform common code: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-inline/
p
oh, right! 🤦 it must have been some IDE glitch that it showed it in red, thanks!
j
however, value classes aren’t compatible with
@JsExport
p
it makes sense since they exist only in compile time
no need for docs adjustment then, the IDE correctly suggests the replacement code
c
However
value class
currently does nothing on non-JVM platforms, it's just here for forward compatibility for when it will do something
p
but it does inline the class if there’s a single field right? otherwise it would be a regression comparing to
inline class
c
As far as I know, there was never any inlining outside of the JVM, which is why they removed the
inline
modifier and replaced it with
@JvmInline
Hm, YouTrack seems to say they were truly inlined in JS IR. No idea, then.
876 Views