Kotlin / kotlinx.serialization

Kotlin multiplatform / multi-format serialization
Apache License 2.0
5.42k stars 620 forks source link

Kotlin 1.3.50 IllegalStateException: IrSimpleFunctionSymbolImpl for WrappedSimpleFunctionDescriptor is already bound #594

Closed luca-heitmann closed 4 years ago

luca-heitmann commented 5 years ago

Describe the bug I somehow get an IllegalStateException during Gradle build when using Kotlin 1.3.50 and this lib with version 0.13.0...

Might be related to https://github.com/Kotlin/kotlinx.serialization/issues/478

To Reproduce I'm trying to get this project working with Kotlin 1.3.50: https://github.com/wojtek-kalicinski/sudoku-android

I only modified these build scripts:

build.gradle

buildscript {

    ext.buildConfig = [
            'compileSdk': 28,
            'minSdk': 21,
            'targetSdk': 27,
            'version': 16,
            'versionName': "1.0.16",
    ]

    ext.versions = [
            'appCompat': '1.1.0-beta01',
            'supportAnnotations': '1.0.0',
            'coreKtx': '1.0.2',
            'constraintLayout': '1.1.3',
            'instantApps': '1.1.0',
            'lifecycles': '2.2.0-alpha01',
            'playServices': '17.0.0',
            'kotlin': '1.3.50',
            'dagger': '2.23.1',
            'navigation': '2.1.0-alpha05',
            'coroutines': '1.3.0-M1'
    ]

    repositories {
        google()
        jcenter()
        maven { url "https://kotlin.bintray.com/kotlinx" }
    }
    dependencies {
        //noinspection GradleDependency
        classpath 'com.android.tools.build:gradle:3.6.0-beta02'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
        classpath 'com.google.gms:google-services:4.3.2'
        classpath "com.google.gms:oss-licenses:0.9.2"
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:${versions.navigation}"
        classpath "org.jetbrains.kotlin:kotlin-serialization:${versions.kotlin}"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://kotlin.bintray.com/kotlinx" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

libsudokusolver/build.gradle

plugins {
    id 'org.jetbrains.kotlin.multiplatform'
}
apply plugin: 'kotlinx-serialization'

kotlin {
    targets {
        fromPreset(presets.jvm, 'jvm')
        fromPreset(presets.js, 'js')

        fromPreset(determineIosPreset(), 'ios')
    }

    sourceSets {
        commonMain {
            dependencies {
                api "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.13.0"
                implementation "org.jetbrains.kotlin:kotlin-stdlib-common:${versions.kotlin}"
            }
        }
        commonTest {
            dependencies {
                implementation "org.jetbrains.kotlin:kotlin-test-common:${versions.kotlin}"
                implementation "org.jetbrains.kotlin:kotlin-test-annotations-common:${versions.kotlin}"
            }
        }

        jvmTest {
            dependencies {
                implementation "org.jetbrains.kotlin:kotlin-test:${versions.kotlin}"
                implementation "org.jetbrains.kotlin:kotlin-test-junit:${versions.kotlin}"
            }
        }
        iosMain {
            dependencies {
                api "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:0.13.0"
            }
        }
    }
}

configurations {
    compileClasspath
}

// If custom preset specified in 'sudoku.preset.name' property, then use it for building.
// Otherwise build for iPhone simulator (by default).
def determineIosPreset() {
    String presetName = project.hasProperty('sudoku.preset.name') ? project.properties['sudoku.preset.name'] : 'iosX64'
    def preset = project.kotlin.presets[presetName]
    println("$project has been configured for $presetName platform.")
    preset
}

Expected behavior a successful build without errors

Environment

Build output

> Task :libsudoku:compileKotlinIos
e: Compilation failed: IrSimpleFunctionSymbolImpl for org.jetbrains.kotlin.backend.common.descriptors.WrappedSimpleFunctionDescriptor@2113c941 is already bound

 * Source files: GenerateBoardSource.kt, LocalBoardSource.kt, SudokuRenderer.kt, Async.kt, BoardRepository.kt
 * Compiler version info: Konan: 1.3.50 / Kotlin: 1.3.50
 * Output kind: LIBRARY

e: java.lang.IllegalStateException: IrSimpleFunctionSymbolImpl for org.jetbrains.kotlin.backend.common.descriptors.WrappedSimpleFunctionDescriptor@2113c941 is already bound
    at org.jetbrains.kotlin.ir.symbols.impl.IrBindableSymbolBase.bind(IrSymbolBase.kt:49)
    at org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl.<init>(IrFunctionImpl.kt:86)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer$deserializeIrFunction$$inlined$withDeserializedIrFunctionBase$lambda$2.invoke(IrModuleDeserializer.kt:949)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer$deserializeIrFunction$$inlined$withDeserializedIrFunctionBase$lambda$2.invoke(IrModuleDeserializer.kt:48)
    at org.jetbrains.kotlin.ir.util.SymbolTable.declareSimpleFunction(SymbolTable.kt:700)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeIrFunction(IrModuleDeserializer.kt:945)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeDeclaration(IrModuleDeserializer.kt:1185)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeStatement(IrModuleDeserializer.kt:192)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeBlock(IrModuleDeserializer.kt:212)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeOperation(IrModuleDeserializer.kt:738)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeExpression(IrModuleDeserializer.kt:810)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeMemberAccessCommon(IrModuleDeserializer.kt:222)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeCall(IrModuleDeserializer.kt:283)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeOperation(IrModuleDeserializer.kt:744)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeExpression(IrModuleDeserializer.kt:810)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeMemberAccessCommon(IrModuleDeserializer.kt:222)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeCall(IrModuleDeserializer.kt:283)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeOperation(IrModuleDeserializer.kt:744)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeExpression(IrModuleDeserializer.kt:810)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeMemberAccessCommon(IrModuleDeserializer.kt:232)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeCall(IrModuleDeserializer.kt:283)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeOperation(IrModuleDeserializer.kt:744)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeExpression(IrModuleDeserializer.kt:810)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeBranch(IrModuleDeserializer.kt:160)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeStatement(IrModuleDeserializer.kt:188)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeWhen(IrModuleDeserializer.kt:586)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeOperation(IrModuleDeserializer.kt:792)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeExpression(IrModuleDeserializer.kt:810)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeBranch(IrModuleDeserializer.kt:160)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeStatement(IrModuleDeserializer.kt:188)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeWhen(IrModuleDeserializer.kt:586)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeOperation(IrModuleDeserializer.kt:792)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeExpression(IrModuleDeserializer.kt:810)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeStatement(IrModuleDeserializer.kt:194)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeBlockBody(IrModuleDeserializer.kt:152)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeStatement(IrModuleDeserializer.kt:186)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.access$deserializeStatement(IrModuleDeserializer.kt:48)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeIrFunction(IrModuleDeserializer.kt:1338)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeDeclaration(IrModuleDeserializer.kt:1185)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeIrClass(IrModuleDeserializer.kt:913)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeDeclaration(IrModuleDeserializer.kt:1183)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeIrClass(IrModuleDeserializer.kt:913)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeDeclaration(IrModuleDeserializer.kt:1183)
    at org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer.deserializeDeclaration(IrModuleDeserializer.kt:1209)
    at org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker.deserializeTopLevelDeclaration(KotlinIrLinker.kt:311)
    at org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker.deserializeAllReachableTopLevels(KotlinIrLinker.kt:368)
    at org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker.findDeserializedDeclarationForDescriptor(KotlinIrLinker.kt:398)
    at org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker.findDeserializedDeclaration(KotlinIrLinker.kt:405)
    at org.jetbrains.kotlin.ir.util.DeclarationStubGenerator$generateClassStub$1.invoke(DeclarationStubGenerator.kt:206)
    at org.jetbrains.kotlin.ir.util.DeclarationStubGenerator$generateClassStub$1.invoke(DeclarationStubGenerator.kt:34)
    at org.jetbrains.kotlin.ir.util.SymbolTable.declareClass(SymbolTable.kt:553)
    at org.jetbrains.kotlin.ir.util.SymbolTable.declareClass$default(SymbolTable.kt:229)
    at org.jetbrains.kotlin.ir.util.DeclarationStubGenerator.generateClassStub$ir_tree(DeclarationStubGenerator.kt:205)
    at org.jetbrains.kotlin.ir.util.ExternalDependenciesGenerator.generateUnboundSymbolsAsDependencies(ExternalDependenciesGenerator.kt:43)
    at org.jetbrains.kotlin.psi2ir.generators.ModuleGenerator.generateUnboundSymbolsAsDependencies(ModuleGenerator.kt:60)
    at org.jetbrains.kotlin.psi2ir.generators.ModuleGenerator.generateUnboundSymbolsAsDependencies$default(ModuleGenerator.kt:51)
    at org.jetbrains.kotlin.psi2ir.Psi2IrTranslator.generateModuleFragment(Psi2IrTranslator.kt:80)
    at org.jetbrains.kotlin.backend.konan.ToplevelPhasesKt$psiToIrPhase$1.invoke(ToplevelPhases.kt:163)
    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:79)
    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:223)
    at org.jetbrains.kotlin.cli.bc.K2Native$Companion$main$1.invoke(K2Native.kt:220)
    at org.jetbrains.kotlin.konan.util.UtilKt.profileIf(Util.kt:26)
    at org.jetbrains.kotlin.konan.util.UtilKt.profile(Util.kt:21)
    at org.jetbrains.kotlin.cli.bc.K2Native$Companion.main(K2Native.kt:222)
    at org.jetbrains.kotlin.cli.bc.K2NativeKt.main(K2Native.kt:304)
    at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:16)

> Task :libsudoku:compileKotlinIos FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':libsudoku:compileKotlinIos'.
> Process 'command '/Applications/Android Studio 3.6 Preview.app/Contents/jre/jdk/Contents/Home/bin/java'' finished with non-zero exit value 2

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 27s
95 actionable tasks: 1 executed, 94 up-to-date
12:50:53: Task execution finished 'build'.
qwwdfsad commented 4 years ago

Should be fixed in the latest version (0.20.0 with Kotlin 1.3.70), please reopen if you still observe this problem