kotlinx.serialization icon indicating copy to clipboard operation
kotlinx.serialization copied to clipboard

Change priority for PolymorphicSerializer inside serializer() function

Open sandwwraith opened this issue 1 year ago • 0 comments

Now, we look up serializers for non-sealed interfaces in SerializersModule first, and only then unconditionally return PolymorphicSerializer. This is done because with old behavior, it was impossible to override interface serializer with context, as interfaces were treated as always having PolymorphicSerializer.

This is a behavioral change, although impact should be minimal, as for most usecases (without modules), serializer will be the same and special workarounds are performed so cache would also work as expected.

Note that KClass.serializer() function will no longer return PolymorphicSerializer for interfaces at all and return null instead. It is OK, because this function is marked with @InternalSerializationApi, and we can change its behavior.

Intrinsics in plugin with changed functionality are expected to be merged in 2.0.0-RC.

Fixes #2060

sandwwraith avatar Feb 09 '24 14:02 sandwwraith