Skip to content

KSP Unresolved References for Sealed Class Default Values #765

@yoobi

Description

@yoobi

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(....)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions