compose-destinations icon indicating copy to clipboard operation
compose-destinations copied to clipboard

KSP Unresolved References for Sealed Class Default Values

Open yoobi opened this issue 2 months ago • 0 comments

When migrating from v1 to v2 KSP fails with "Unresolved reference" errors for sealed class objects used as default values in NavArgs.

Root cause: v2's KSP code generator extracts default values and uses them in generated files, but without explicit imports, they become unqualified and unresolvable.

In v1 I used to do and it worked

enum class class ProfileScreenMode {
    Edit
    Select
}

data class ProfileSelectScreenNavArgs(
    val screenMode: ProfileScreenMode = Select,
    val profileId: Int
)

@Destination(navArgs = ProfileSelectScreenNavArgs::class)
@Composable
fun ProfileSelectScreen(....)

now in v2 this doesn't compile because ksp complains about unresolved Select

enum class class ProfileScreenMode {
    Edit
    Select
}

data class ProfileSelectScreenNavArgs(
    val screenMode: ProfileScreenMode = Select,
    val profileId: Int
)

@Destination<RootGraph>(navArgs = ProfileSelectScreenNavArgs::class)
@Composable
fun ProfileSelectScreen(....)

yoobi avatar Nov 28 '25 07:11 yoobi