Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KSP2: "Unresolved reference" in common code for entities annotated with SealedObjectInstances #1651

Open
Tapchicoma opened this issue Dec 7, 2023 · 1 comment

Comments

@Tapchicoma
Copy link

Originally reported in Kotlin bug tracker here

In Kotlin multiplatform module that depends on SealedObjectInstances KSP library to generate the sealedObjectInstances() extension on the Entity Companion object build fails with Kotlin 2.0.0-Beta1 and KSP 2.0.0-Beta1-1.0.15 versions:

e: file:///home/runner/work/SealedObjectInstances/SealedObjectInstances/multi/src/commonMain/kotlin/com/example/Entity.kt:27:47 Unresolved reference 'sealedObjectInstances'.
> Task :multi:compileKotlinJvm FAILED

Repro is available here: SimonMarquis/SealedObjectInstances#163

@SimonMarquis
Copy link

The current workaround is to provides a bridge layer of actual / expect (SimonMarquis/SealedObjectInstances@2959384)

// src/commonMain/kotlin/com/example/Entity.kt
internal expect fun Entity.Companion.all(): Set<Entity>
// src/jvmMain/kotlin/com/example/Entity.jvm.kt
internal actual fun Entity.Companion.all(): Set<Entity> = sealedObjectInstances()

Note that the workaround mentioned here does not seem to work:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants