What is the best way to work with value classes in...
# multiplatform
p
What is the best way to work with value classes in MPP? If I create them in common scope jvm side complains about lack of annotation @JvmInline, but if I add this annotation then js side complains about unresolved reference of @JvmInline.
e
use
@JvmInline
in Java and common sourcesets, don't use it in JS and native sourcesets
p
But value class is defined in common sourceset. How can i strip this annotation for particular platform?
v
commonMain:
Copy code
expect interface NameYourAnnotation
jvmMain:
Copy code
actual typealias NameYourAnnotation = JvmInline
jsMain:
Copy code
actual interface NameYourAnnotation
- This should resolve it
e
If you use
@JvmInline
in common, js gives you an error? I'm pretty sure I've seen that work.
e
Yes. JvmInline is an
@OptionalExpectation
in common, meaning that it is fine that it only
actual
on some platforms