google / google/ksp

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

Open
#1,651 3 comments 4 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
3.5k
Forks
415
Avg merge
1d 2h
Merged PRs (30d)
53

Description

Originally reported in Kotlin bug tracker [here](https://youtrack.jetbrains.com/issue/KT-63888/K2-unresolved-reference-on-expected-KSP-generated-extension)

In Kotlin multiplatform module that depends on [SealedObjectInstances](https://github.com/SimonMarquis/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: https://github.com/SimonMarquis/SealedObjectInstances/pull/163

Contributor guide

Open the contributing guide

Research direction

Start with the reproduction linked in pull request 163 and inspect multi/src/commonMain/kotlin/com/example/Entity.kt at line 27. Reproduce the failure with Kotlin 2.0.0-Beta1 and KSP 2.0.0-Beta1-1.0.15, then trace why the generated sealedObjectInstances() extension is unavailable in common code. Done means the multiplatform module compiles without the unresolved-reference error.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.