diff --git a/serialization/src/commonMain/kotlin/nl/adaptivity/xmlutil/serialization/DefaultFormatCache.kt b/serialization/src/commonMain/kotlin/nl/adaptivity/xmlutil/serialization/DefaultFormatCache.kt index 150b1a438..b012f819b 100644 --- a/serialization/src/commonMain/kotlin/nl/adaptivity/xmlutil/serialization/DefaultFormatCache.kt +++ b/serialization/src/commonMain/kotlin/nl/adaptivity/xmlutil/serialization/DefaultFormatCache.kt @@ -111,7 +111,18 @@ public class DefaultFormatCache : FormatCache() { val canBeAttribute: Boolean ) - private data class TypeKey(val namespace: String, val descriptor: SerialDescriptor) + private data class TypeKey(val namespace: String, val descriptor: SerialDescriptor) { + override fun equals(other: Any?): Boolean { + return when { + other !is TypeKey -> false + namespace != other.namespace -> false + descriptor != other.descriptor -> false + (0 until descriptor.elementsCount).any { descriptor.getElementName(it) != other.descriptor.getElementName(it) } -> false + else -> true + } + return super.equals(other) + } + } private companion object { @JvmStatic diff --git a/serialization/src/commonMain/kotlin/nl/adaptivity/xmlutil/serialization/structure/XmlDescriptor.kt b/serialization/src/commonMain/kotlin/nl/adaptivity/xmlutil/serialization/structure/XmlDescriptor.kt index 792c13a8b..db3f05647 100644 --- a/serialization/src/commonMain/kotlin/nl/adaptivity/xmlutil/serialization/structure/XmlDescriptor.kt +++ b/serialization/src/commonMain/kotlin/nl/adaptivity/xmlutil/serialization/structure/XmlDescriptor.kt @@ -1891,11 +1891,11 @@ public class ParentInfo( other as ParentInfo - if (descriptor != other.descriptor) return false if (index != other.index) return false if (overriddenSerializer != other.overriddenSerializer) return false if (elementUseNameInfo != other.elementUseNameInfo) return false - return elementUseOutputKind == other.elementUseOutputKind + if (elementUseOutputKind != other.elementUseOutputKind) return false + return descriptor == other.descriptor } override fun hashCode(): Int { diff --git a/serialization/src/commonMain/kotlin/nl/adaptivity/xmlutil/serialization/structure/XmlTypeDescriptor.kt b/serialization/src/commonMain/kotlin/nl/adaptivity/xmlutil/serialization/structure/XmlTypeDescriptor.kt index e7b72eff1..973a2dc0c 100644 --- a/serialization/src/commonMain/kotlin/nl/adaptivity/xmlutil/serialization/structure/XmlTypeDescriptor.kt +++ b/serialization/src/commonMain/kotlin/nl/adaptivity/xmlutil/serialization/structure/XmlTypeDescriptor.kt @@ -123,8 +123,16 @@ public class XmlTypeDescriptor internal constructor( other as XmlTypeDescriptor - if (serialDescriptor != other.serialDescriptor) return false - return typeNameInfo == other.typeNameInfo + return when { + typeNameInfo != other.typeNameInfo -> false + serialDescriptor != other.serialDescriptor -> false + (0 until serialDescriptor.elementsCount).any { + serialDescriptor.getElementName(it) != other.serialDescriptor.getElementName( + it + ) + } -> false + else -> true + } } override fun hashCode(): Int { diff --git a/serialization/src/commonTest/kotlin/nl/adaptivity/xml/serialization/regressions/ElementNames254.kt b/serialization/src/commonTest/kotlin/nl/adaptivity/xml/serialization/regressions/ElementNames254.kt index 5e0652a13..2ca612cb3 100644 --- a/serialization/src/commonTest/kotlin/nl/adaptivity/xml/serialization/regressions/ElementNames254.kt +++ b/serialization/src/commonTest/kotlin/nl/adaptivity/xml/serialization/regressions/ElementNames254.kt @@ -41,11 +41,8 @@ class ElementNames254 { @BeforeTest fun setup() { - xml= XML { - recommended { - // TODO Remove this check once a fix exists in the library. - formatCache = FormatCache.Dummy - } + xml = XML { + recommended_0_90_2() indent = 4 } }