https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
c

Chrys

11/06/2023, 9:00 AM
is there a way to skip the expect/actual for one platform. Say I have an expected class but only actual implementaion for android and web, and want to skip the jvm implementation for that specific class
z

zsmb

11/06/2023, 9:29 AM
What do you expect to happen when that code is called on the JVM?
c

Chrys

11/06/2023, 10:54 AM
I'd have same models for jvm defined in the backend module itself
That's to overcome an issue with annotation processors I described in my previous main post
r

russhwolf

11/06/2023, 2:13 PM
You can define a source set that's shared between only web and android, and put your expect declaration there. Or you can use an interface instead of expect class. Optional expectation won't help you because it can only be used for annotations.
c

Chrys

11/06/2023, 2:15 PM
got any example use oof optional expectation? I did get your last sentence: " it can only be used for annotations"
r

russhwolf

11/06/2023, 2:17 PM
If you do
@OptionalExpectation expect annotation class Foo
then you don't need to do
actual annotation class Foo
for every platform. But you can't do
@OptionalExpection expect class Foo
if
Foo
is not an
annotation class
thank you color 1
It lets you do
@Foo
in common without having an implementation for
Foo
for all platforms. But that's the only use case
c

Chrys

11/06/2023, 2:18 PM
so it's not for type of class?
r

russhwolf

11/06/2023, 2:19 PM
It's only for
annotation class
c

Chrys

11/06/2023, 2:20 PM
thanks
2 Views