Fixed serialization with custom serializer for parametrized sealed class
#KT-50764 Fixed #KT-50718 Fixed Fixes Kotlin/kotlinx.serialization#1705
This commit is contained in:
+3
-2
@@ -1135,9 +1135,10 @@ interface IrBuilderExtension {
|
||||
} ?: return null
|
||||
|
||||
val adjustedArgs: List<IrExpression> =
|
||||
if (baseClass.descriptor.isSealed() || baseClass.descriptor.modality == Modality.ABSTRACT) {
|
||||
// if typeArgs.size == args.size then the serializer is custom - we need to use the actual serializers from the arguments
|
||||
if ((typeArgs.size != args.size) && (baseClass.descriptor.isSealed() || baseClass.descriptor.modality == Modality.ABSTRACT)) {
|
||||
val serializer = findStandardKotlinTypeSerializer(baseClass.module, context.irBuiltIns.unitType.toKotlinType())!!
|
||||
// workaround for sealed and classes - the `serializer` function expects non-null serializers, but does not use them, so serializers of any type can be passed
|
||||
// workaround for sealed and abstract classes - the `serializer` function expects non-null serializers, but does not use them, so serializers of any type can be passed
|
||||
List(baseClass.typeParameters.size) { irGetObject(serializer) }
|
||||
} else {
|
||||
args
|
||||
|
||||
Reference in New Issue
Block a user