Change theme
Help
Press space for more information.
Show links for this issue (Shortcut: i, l)
Copy issue ID
Previous Issue (Shortcut: k)
Next Issue (Shortcut: j)
Sign in to use full features.
Vote: I am impacted
Notification menu
Refresh (Shortcut: Shift+r)
Go home (Shortcut: u)
Pending code changes (auto-populated)
View issue level access limits(Press Alt + Right arrow for more information)
Request for new functionality
View staffing
Description
The most recent way to setup Room in a KMP project that uses Kotlin 2.0 involves defining an
expect object
that extendsRoomDatabaseConstructor
and that Room annotation processor will generate theactual
implementation.The setup works well when the
@Database
along with theexpect object
is defined in a 'common' source set but when it is defined in platform source set, saylinuxX64
then Kotlin will produce the following warning:The reason is that this is no longer allowed with K2 due to different compilation model, see:https://youtrack.jetbrains.com/issue/KT-55177/Deprecate-declaration-of-expect-and-actual-counterparts-of-same-class-in-one-module
The current workaround is to define Room and the constructor object in a common native source set, such as 'nativeMain' or similar.
We need to find a solution for this, Android and JVM don't have this issue since they can skip declaring the constructor object. But native targets (and JS / WASM in the future) will need the constructor mechanism.