I have an issue compiling some code that compiles ...
# kotlin-native
s
I have an issue compiling some code that compiles for the jvm and android targets but fails to compile for iOS. From what I can tell it may be serialization related but I'm not 100% positive. I'm using versions kotlin_version = 1.3.41 & kotlin_serialization_version = 0.11.1
If I switch to using the eap versions the code will compile but I get a number of odd warnings.
Copy code
w: [IR VALIDATION] BEFORE Compiler Phase @IrLowering: org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl@19354b2f for val tmp0_serialDesc: kotlinx.serialization.internal.SerialClassDescImpl defined in [package omitted].remote.Expression.Verified.`$serializer`[IrTemporaryVariableDescriptorImpl@d04e82b] has unexpected parent org.jetbrains.kotlin.ir.declarations.impl.IrClassImpl@7508aa16
w: [IR VALIDATION] AFTER Compiler Phase @IrLowering: org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl@19354b2f for val tmp0_serialDesc: kotlinx.serialization.internal.SerialClassDescImpl defined in [package omitted]/.remote.Expression.Verified.`$serializer`[IrTemporaryVariableDescriptorImpl@d04e82b] has unexpected parent org.jetbrains.kotlin.ir.declarations.impl.IrClassImpl@7508aa16
w: [path omitted]//remote/Expression.kt: (18, 30): [IR VALIDATION] Duplicate IR node
CONST Null type=kotlin.Nothing? value=null
w: [path omitted]/core/dice/remote/ExpressionGroupModifiers.kt: (19, 48): [IR VALIDATION] Duplicate IR node
k
Not sure how deep you want to go on it, but you can debug the compiler and maybe figure out what exactly is blowing up: https://medium.com/@kpgalligan/debugging-kotlin-natives-compiler-3cba9daec076
s
I commented out all of the serialization annotations and code, and slowly restored them until I narrowed it down to the culprit that is breaking the compiler. I have a custom serializer that is causing the break if it overrides the
deserialize
or
serialize
method.
Copy code
@Serializer(forClass = ExpressionResultModHolder::class)
    companion object : KSerializer<ExpressionResultModHolder> {
        override val descriptor: SerialDescriptor = SerialClassDescImpl("ExpressionResultModHolder")
        //This override breaks the compiler and gives the IllegalStateException above.
        override fun deserialize(decoder: Decoder): ExpressionResultModHolder { 
    ...
}
k
Ah. Yeah, that’s usually my method. Compiler binary search ([comment out half]; [still crashing] ? [comment out half] : [swap-comment with first half])
s
Using the EAP version works but I do see the duplicate IR node warnings with or without the custom serializer that I don't see when I compile for the jvm.
k
No idea on that one
a
It looks like you faced something like this - https://youtrack.jetbrains.com/issue/KT-32475
s
Ahh, yes that is it. Thank you.