Coerce property value from correct type after retrieving it
#KT-25497 fixed Fixes https://github.com/Kotlin/kotlinx.serialization/issues/434
This commit is contained in:
+3
-3
@@ -102,15 +102,15 @@ fun InstructionAdapter.genKOutputMethodCall(
|
||||
val sti = generator.getSerialTypeInfo(property, propertyType)
|
||||
val useSerializer = if (fromClassStartVar == null) stackValueSerializerInstanceFromSerializer(classCodegen, sti, generator)
|
||||
else stackValueSerializerInstanceFromClass(classCodegen, sti, fromClassStartVar, generator)
|
||||
if (!sti.unit) ImplementationBodyCodegen.genPropertyOnStack(
|
||||
val actualType = if (!sti.unit) ImplementationBodyCodegen.genPropertyOnStack(
|
||||
this,
|
||||
expressionCodegen.context,
|
||||
property.descriptor,
|
||||
propertyOwnerType,
|
||||
ownerVar,
|
||||
classCodegen.state
|
||||
)
|
||||
StackValue.coerce(propertyType, sti.type, this)
|
||||
) else null
|
||||
actualType?.type?.let { type -> StackValue.coerce(type, sti.type, this) }
|
||||
invokeinterface(
|
||||
kOutputType.internalName,
|
||||
CallingConventions.encode + sti.elementMethodPrefix + (if (useSerializer) "Serializable" else "") + CallingConventions.elementPostfix,
|
||||
|
||||
+3
-2
@@ -143,7 +143,8 @@ class SerializableCodegenImpl(
|
||||
val writeLabel = Label()
|
||||
val nonWriteLabel = Label()
|
||||
// obj.prop != DEFAULT_VAL
|
||||
ImplementationBodyCodegen.genPropertyOnStack(
|
||||
val propAsmType = classCodegen.typeMapper.mapType(property.type)
|
||||
val actualType: JvmKotlinType = ImplementationBodyCodegen.genPropertyOnStack(
|
||||
this,
|
||||
exprCodegen.context,
|
||||
property.descriptor,
|
||||
@@ -151,7 +152,7 @@ class SerializableCodegenImpl(
|
||||
thisI,
|
||||
classCodegen.state
|
||||
)
|
||||
val propAsmType = classCodegen.typeMapper.mapType(property.type)
|
||||
StackValue.coerce(actualType.type, propAsmType, this)
|
||||
val lhs = StackValue.onStack(propAsmType)
|
||||
val (expr, _) = initializersMapper(property)
|
||||
exprCodegen.gen(expr, propAsmType)
|
||||
|
||||
Reference in New Issue
Block a user