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

UninitializedPropertyAccessException thrown during compilation with a value class param #442

Open
ZacSweers opened this issue Jun 12, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@ZacSweers
Copy link
Owner

The following snippet seems to result in a compiler error, unsure if it's a bug in kotlinc or moshix doing something wrong

/** Indicates this issue should be retried after a [delay]. */
@TypeLabel("delayed")
@JsonClass(generateAdapter = true)
data class RetryDelayed(val delay: Duration = 1.minutes) : RetrySignal

Results in this

e: org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering
File being compiled: /Users/zacsweers/dev/slack/oss/kotlin-cli-util/src/main/kotlin/slack/cli/exec/RetrySignal.kt
The root cause kotlin.UninitializedPropertyAccessException was thrown at: org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl.getParent(IrValueParameterImpl.kt:43)
        at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException(CodegenUtil.kt:253)
        at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException$default(CodegenUtil.kt:237)
        at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invokeSequential(performByIrFile.kt:68)
        at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invoke(performByIrFile.kt:55)
        at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invoke(performByIrFile.kt:41)
        at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.phaseBody(CompilerPhase.kt:147)
        at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedCompilerPhase.invoke(CompilerPhase.kt:94)
        at org.jetbrains.kotlin.backend.common.phaser.CompositePhase.invoke(PhaseBuilders.kt:29)
        at org.jetbrains.kotlin.backend.common.phaser.CompositePhase.invoke(PhaseBuilders.kt:16)
        at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.phaseBody(CompilerPhase.kt:147)
        at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedCompilerPhase.invoke(CompilerPhase.kt:94)
        at org.jetbrains.kotlin.backend.common.phaser.CompilerPhaseKt.invokeToplevel(CompilerPhase.kt:43)
        at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.invokeLowerings(JvmIrCodegenFactory.kt:308)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.runLowerings(KotlinToJVMBytecodeCompiler.kt:331)
@ZacSweers ZacSweers added the bug Something isn't working label Jun 12, 2023
@ZacSweers
Copy link
Owner Author

Removing the default value works around it for now

@mhelder
Copy link
Contributor

mhelder commented Jun 28, 2024

Gave this a quick try on MoshiX 0.27.1. The following seems to compile just fine:

@JsonClass(generateAdapter = true, generator = "sealed:type")
sealed class Message {

    @TypeLabel("success")
    @JsonClass(generateAdapter = true)
    data class Success(
        @Json(name = "value")
        val value: Duration = 1.minutes
    ) : Message()

    @DefaultObject
    object Unknown : Message()
}

(Kotlin 1.9.21, KSP 1.9.21-1.0.16)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants