As a refinement of #26298, we should disable out of the box open polymorphic serialization for collections using something like:
// Pseudocode, not tested
fun hasPolymorphism(serializer: KSerializer<*>): Boolean = hasPolymorphism(serializer.descriptor)
fun hasPolymorphism(descriptor: SerialDescriptor): Boolean {
if (descriptor.kind == PolymorphicKind.OPEN.INSTANCE) return true
for (i in 0 until descriptor.elementsCount) {
// TODO circuit breaker for recursive types
if (hasPolymorphism(descriptor.getElementDescriptor(i)) return true
}
return false
}