Skip to content

Commit 20fc0c1

Browse files
committed
chore: Using conventional name and renaming isPolimorphic
1 parent 7e227ed commit 20fc0c1

File tree

1 file changed

+4
-7
lines changed
  • formats/hocon/src/main/kotlin/kotlinx/serialization/hocon

1 file changed

+4
-7
lines changed

formats/hocon/src/main/kotlin/kotlinx/serialization/hocon/Hocon.kt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public sealed class Hocon(
145145

146146
}
147147

148-
private inner class ConfigReader(val conf: Config, private val isPolymorph: Boolean = false) : ConfigConverter<String>() {
148+
private inner class ConfigReader(val conf: Config, private val isPolymorphic: Boolean = false) : ConfigConverter<String>() {
149149
private var ind = -1
150150

151151
override fun decodeElementIndex(descriptor: SerialDescriptor): Int {
@@ -162,10 +162,8 @@ public sealed class Hocon(
162162
if (parentName.isEmpty()) childName else "$parentName.$childName"
163163

164164
override fun SerialDescriptor.getTag(index: Int): String {
165-
return if (!isPolymorph) composeName(
166-
currentTagOrNull.orEmpty(),
167-
getConventionElementName(index, useConfigNamingConvention)
168-
) else getElementName(index)
165+
val conventionName = getConventionElementName(index, useConfigNamingConvention)
166+
return if (!isPolymorphic) composeName(currentTagOrNull.orEmpty(), conventionName) else conventionName
169167
}
170168

171169
override fun decodeNotNullMark(): Boolean {
@@ -215,8 +213,7 @@ public sealed class Hocon(
215213

216214
override fun beginStructure(descriptor: SerialDescriptor): CompositeDecoder =
217215
when {
218-
// Polymorph should always be object-like I believe?
219-
descriptor.kind.objLike -> ConfigReader(conf, isPolymorph = true)
216+
descriptor.kind.objLike -> ConfigReader(conf, isPolymorphic = true)
220217
else -> this
221218
}
222219

0 commit comments

Comments
 (0)