Hi, id like some guidance regarding expect/actual....
# multiplatform
v
Hi, id like some guidance regarding expect/actual.
expect and corresponding actual are declared in the same module, which will be prohibited in Kotlin 2.0. See https:// youtrack. jetbrains. com/ issue/ KT-55177
more details on thread.
on commonMain/database, i have a expect DatabaseFactory, and on androidMain/Database.android i have the actual DatabaseFactory implementation.
when it says they are declared in the same module and it will be prohibited, what do i need to do to implement such functionality? i need to create a new gradle module?
d
I know you've shown files across
common
vs
android
source-sets here; but my hunch is that the term 'module' is being overloaded here. Since I recall IntelliJ's internal model of KMP is a 'module per source set' the real meaning of the message may merely be that they have to be in different source-sets (as expected). Is it possible you've accidently got an
actual
in the same source-set as the
expect
?
v
id think no, i have two sourceSets, one for common for androidMain. https://github.com/mrVinxyz/kql/tree/multiplatform
d
Then could it be that because your project is not truly multi-platform; the toolchain is optimising this to a single module (internal representation) and thereby triggering the same error. You could try adding a JVM target and seeing if the issue goes away.
When you have one target only;
commonMain
and
androidMain
are effectively the same thing as
commonMain
is the computed intersection of the API's of your included targets.
v
yeah, it seems like you're right, i added a jvm target and the warning is gone
👍 1
m
In the screen shot, you can see that both
androidMain
and `commonMain`are marked as belonging to the
main
source set, which is the name used for the Android main source set.
🕵️‍♂️ 1