-
Notifications
You must be signed in to change notification settings - Fork 43
Value class not being flattened in polymorphic scope #280
Copy link
Copy link
Closed
Labels
indevThe issue is fixed/implemented in the dev branchThe issue is fixed/implemented in the dev branch
Description
In an attempt to model some XML resembling
<outer>
Hello, world!
<inner>This is some mixed content!</inner>
Here's some more text!
</outer>Where the text and inner can be in any arbitrary order, of zero or more items.
I have created a class hierarchy that looks like
@Serializable
data class Outer(
@XmlValue
val content: List<Content>
) {
@Serializable
sealed interface Content;
@Serializable
value class Text(val content: String): Content
@Serializable
data class Inner(
@XmlValue
val innerContent: String
): Content
}However, the serializer spits back `Invalid XML value at position: 11:30: Serializer for subclass 'kotlin.String' is not found in the polymorphic scope of 'Content'.
Based on https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/value-classes.md, I would expect the value class to be "flattened" into a String automatically, but it seems like this is not happening? I'm no expert in XML in general, so maybe I've missed something?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
indevThe issue is fixed/implemented in the dev branchThe issue is fixed/implemented in the dev branch