From ef3ecae844043d2650e1f7f4b54f74c4ff99b99b Mon Sep 17 00:00:00 2001 From: Danielle Voznyy Date: Fri, 18 Oct 2024 12:39:53 -0400 Subject: [PATCH] fix: add geary to default namespaces in PolymorphicListAsMapSerializer --- .../serializers/PolymorphicListAsMapSerializer.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/geary-serialization/src/commonMain/kotlin/com/mineinabyss/geary/serialization/serializers/PolymorphicListAsMapSerializer.kt b/addons/geary-serialization/src/commonMain/kotlin/com/mineinabyss/geary/serialization/serializers/PolymorphicListAsMapSerializer.kt index 0b3187b1..d1e667be 100644 --- a/addons/geary-serialization/src/commonMain/kotlin/com/mineinabyss/geary/serialization/serializers/PolymorphicListAsMapSerializer.kt +++ b/addons/geary-serialization/src/commonMain/kotlin/com/mineinabyss/geary/serialization/serializers/PolymorphicListAsMapSerializer.kt @@ -99,12 +99,13 @@ open class PolymorphicListAsMapSerializer( if (key.startsWith("kotlin.")) { return@runCatching serializersModule.getPolymorphic(polymorphicSerializer.baseClass, key) as KSerializer } + val defaultNamespaces = namespaces.plus("geary").toSet() val parsedKey = "${config.prefix}$key".fromCamelCaseToSnakeCase() return@runCatching (if (parsedKey.hasNamespace()) serializersModule.getPolymorphic(polymorphicSerializer.baseClass, parsedKey) - else namespaces.firstNotNullOfOrNull { namespace -> + else defaultNamespaces.firstNotNullOfOrNull { namespace -> serializersModule.getPolymorphic(polymorphicSerializer.baseClass, "$namespace:$parsedKey") - } ?: error("No serializer found for $parsedKey in any of the namespaces $namespaces")) + } ?: error("No serializer found for $parsedKey in any of the namespaces $defaultNamespaces")) as? KSerializer ?: error("Serializer for $parsedKey is not a component serializer") }