inline fun <Base : Any> SerializersModuleBuilder.polymorphic(    baseClass: KClass<Base>,     baseSerializer: KSerializer<Base>? = null,     builderAction: PolymorphicModuleBuilder<Base>.() -> Unit = {})

Creates a builder to register subclasses of a given baseClass for polymorphic serialization. If baseSerializer is not null, registers it as a serializer for baseClass, which is useful if the base class is serializable itself. To register subclasses, PolymorphicModuleBuilder.subclass builder function can be used.

If a serializer already registered for the given KClass in the given scope, an IllegalArgumentException is thrown. To override registered serializers, combine built module with another using SerializersModule.overwriteWith.

See also