Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent kotlinx.serialization usage on collection of interfaces #26371

Closed
sdeleuze opened this issue Jan 12, 2021 · 0 comments
Closed

Prevent kotlinx.serialization usage on collection of interfaces #26371

sdeleuze opened this issue Jan 12, 2021 · 0 comments
Assignees
Milestone

Comments

@sdeleuze
Copy link
Contributor

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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant