Kotlin / kotlinx.serialization

Kotlin multiplatform / multi-format serialization
Apache License 2.0
5.34k stars 618 forks source link

Compilation does not pass during the task of compileTestKotlinLinuxX64 #612

Open inoutch opened 4 years ago

inoutch commented 4 years ago

Describe the bug I think that the title error is caused by testing using (inheriting) the Serializable class in Main. This error did not occur with kotlin version 1.3.50 and kotlin-serialization 0.13.0.

To Reproduce https://github.com/inoutch/kotchan-game-manager/tree/bug-report

> Task :compileTestKotlinLinuxX64
e: Compilation failed: org.jetbrains.kotlin.backend.common.descriptors.WrappedPropertyDescriptor@129d65a0 is not bound

 * Source files: <some kt files>
 * Compiler version info: Konan: 1.3.60 / Kotlin: 1.3.60
 * Output kind: LIBRARY

e: java.lang.IllegalStateException: org.jetbrains.kotlin.backend.common.descriptors.WrappedPropertyDescriptor@129d65a0 is not bound
    at org.jetbrains.kotlin.backend.common.descriptors.WrappedDeclarationDescriptor.getOwner(WrappedDescriptors.kt:98)
    at org.jetbrains.kotlin.backend.common.descriptors.WrappedPropertyDescriptor.getReturnType(WrappedDescriptors.kt:816)
    at org.jetbrains.kotlin.backend.common.descriptors.WrappedPropertyDescriptor.getType(WrappedDescriptors.kt:820)
    at org.jetbrains.kotlin.ir.util.DeclarationStubGenerator.generateFieldStub(DeclarationStubGenerator.kt:140)
    at org.jetbrains.kotlin.ir.util.ExternalDependenciesGenerator.generateUnboundSymbolsAsDependencies(ExternalDependenciesGenerator.kt:59)
    at org.jetbrains.kotlin.psi2ir.generators.ModuleGenerator.generateUnboundSymbolsAsDependencies(ModuleGenerator.kt:63)
    at org.jetbrains.kotlin.psi2ir.Psi2IrTranslator.generateModuleFragment(Psi2IrTranslator.kt:82)
    at org.jetbrains.kotlin.backend.konan.ToplevelPhasesKt$psiToIrPhase$1.invoke(ToplevelPhases.kt:175)
    at org.jetbrains.kotlin.backend.konan.ToplevelPhasesKt$psiToIrPhase$1.invoke(ToplevelPhases.kt)
    at org.jetbrains.kotlin.backend.common.phaser.PhaseBuildersKt$namedOpUnitPhase$1.invoke(PhaseBuilders.kt:115)
    at org.jetbrains.kotlin.backend.common.phaser.PhaseBuildersKt$namedOpUnitPhase$1.invoke(PhaseBuilders.kt:113)
    at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedPhaseWrapper$runBody$1.invoke(CompilerPhase.kt:128)
    at org.jetbrains.kotlin.backend.common.phaser.CompilerPhaseKt.downlevel(CompilerPhase.kt:24)
    at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedPhaseWrapper.runBody(CompilerPhase.kt:127)
    at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedPhaseWrapper.invoke(CompilerPhase.kt:105)
    at org.jetbrains.kotlin.backend.common.phaser.CompositePhase.invoke(PhaseBuilders.kt:28)
    at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedPhaseWrapper$runBody$1.invoke(CompilerPhase.kt:128)
    at org.jetbrains.kotlin.backend.common.phaser.CompilerPhaseKt.downlevel(CompilerPhase.kt:24)
    at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedPhaseWrapper.runBody(CompilerPhase.kt:127)
    at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedPhaseWrapper.invoke(CompilerPhase.kt:105)
    at org.jetbrains.kotlin.backend.common.phaser.CompilerPhaseKt.invokeToplevel(CompilerPhase.kt:42)
    at org.jetbrains.kotlin.backend.konan.KonanDriverKt.runTopLevelPhases(KonanDriver.kt:27)
    at org.jetbrains.kotlin.cli.bc.K2Native.doExecute(K2Native.kt:74)
    at org.jetbrains.kotlin.cli.bc.K2Native.doExecute(K2Native.kt:34)
    at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:84)
    at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:42)
    at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:104)
    at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:82)
    at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:50)
    at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMainNoExit(CLITool.kt:215)
    at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMain(CLITool.kt:207)
    at org.jetbrains.kotlin.cli.bc.K2Native$Companion$main$1.invoke(K2Native.kt:225)
    at org.jetbrains.kotlin.cli.bc.K2Native$Companion$main$1.invoke(K2Native.kt:222)
    at org.jetbrains.kotlin.util.UtilKt.profileIf(Util.kt:27)
    at org.jetbrains.kotlin.util.UtilKt.profile(Util.kt:21)
    at org.jetbrains.kotlin.cli.bc.K2Native$Companion.main(K2Native.kt:224)
    at org.jetbrains.kotlin.cli.bc.K2NativeKt.main(K2Native.kt:304)
    at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:16)

Expected behavior Compile successfully

Environment

auras commented 4 years ago

I can confirm there is an issue with 0.14.0 I get the same error when trying to build for iOS, but not with 0.13.0

charlag commented 4 years ago

I've opened an issue with kotlin/native https://github.com/JetBrains/kotlin-native/issues/3900 but it might be just a serialization bug. In any case, check linked issue for more info.

update: I get it with both 0.14.0 and 0.13.0 so I think it's dependent on Kotlin version (which I tried to change but the compiler printed the same version so I couldn't try it out)

charlag commented 4 years ago

There's a corresponding issue in Kotlin tracker: https://youtrack.jetbrains.com/issue/KT-36880

seems like klib-based libraries are not ready yet?

SvyatoslavScherbina commented 4 years ago

KT-36880 is likely unrelated to this issue.

seems like klib-based libraries are not ready yet?

It is not clear what exactly you mean by this. Kotlin/Native doesn't support any other kind of libraries but klib.

charlag commented 4 years ago

I referred to this:

We don't advertise klib based mpp as a feature yet. We have a tiny preliminary implementation which is under -Xklib-mpp flag.

as far as I understood, cinterop generates klib files and while K/N itself had no problems but they couldn't be properly processed by other modules in my project. I might be wrong and it's just another bug

SvyatoslavScherbina commented 4 years ago

"klib based mpp" != klib. klibs are generated not only by cinterop, but by compiler itself too, from Kotlin source code.

yackermann commented 4 years ago

Any update on this issue or workaround? (Aside from putting all classes in one file, which I am not keen too since it will be 5000 lines long)