Fix problem with encodeUnitElement : Unit instance is not needed in Native IR
This commit is contained in:
+17
-14
@@ -193,28 +193,31 @@ class SerializerIrGenerator(val irClass: IrClass, override val compilerContext:
|
|||||||
for ((index, property) in orderedProperties.filter { !it.transient }.withIndex()) {
|
for ((index, property) in orderedProperties.filter { !it.transient }.withIndex()) {
|
||||||
// output.writeXxxElementValue(classDesc, index, value)
|
// output.writeXxxElementValue(classDesc, index, value)
|
||||||
val sti = getSerialTypeInfo(property)
|
val sti = getSerialTypeInfo(property)
|
||||||
val innerSerial = serializerInstance(this@SerializerIrGenerator, serializableDescriptor, sti.serializer, property.module, property.type, property.genericIndex)
|
val innerSerial = serializerInstance(
|
||||||
val elementCall = if (innerSerial == null) {
|
this@SerializerIrGenerator,
|
||||||
val writeFunc =
|
serializableDescriptor,
|
||||||
|
sti.serializer,
|
||||||
|
property.module,
|
||||||
|
property.type,
|
||||||
|
property.genericIndex
|
||||||
|
)
|
||||||
|
val (writeFunc, args: List<IrExpression>) = if (innerSerial == null) {
|
||||||
|
val f =
|
||||||
kOutputClass.referenceMethod("${CallingConventions.encode}${sti.elementMethodPrefix}${CallingConventions.elementPostfix}")
|
kOutputClass.referenceMethod("${CallingConventions.encode}${sti.elementMethodPrefix}${CallingConventions.elementPostfix}")
|
||||||
irInvoke(
|
val args = mutableListOf(irGet(localSerialDesc), irInt(index))
|
||||||
irGet(localOutput),
|
if (sti.elementMethodPrefix != "Unit") args += property.irGet()
|
||||||
writeFunc,
|
f to args
|
||||||
irGet(localSerialDesc),
|
|
||||||
irInt(index),
|
|
||||||
property.irGet()
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
val writeFunc = kOutputClass.referenceMethod("${CallingConventions.encode}${sti.elementMethodPrefix}Serializable${CallingConventions.elementPostfix}")
|
val f =
|
||||||
irInvoke(
|
kOutputClass.referenceMethod("${CallingConventions.encode}${sti.elementMethodPrefix}Serializable${CallingConventions.elementPostfix}")
|
||||||
irGet(localOutput),
|
f to listOf(
|
||||||
writeFunc,
|
|
||||||
irGet(localSerialDesc),
|
irGet(localSerialDesc),
|
||||||
irInt(index),
|
irInt(index),
|
||||||
innerSerial,
|
innerSerial,
|
||||||
property.irGet()
|
property.irGet()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
val elementCall = irInvoke(irGet(localOutput), writeFunc, *args.toTypedArray())
|
||||||
|
|
||||||
// check for call to .shouldEncodeElementDefault
|
// check for call to .shouldEncodeElementDefault
|
||||||
if (!property.optional) {
|
if (!property.optional) {
|
||||||
|
|||||||
Reference in New Issue
Block a user