Skip to content

Commit

Permalink
fix(pub): Properly end the input structure when parsing specs
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
  • Loading branch information
sschuberth committed Oct 15, 2024
1 parent 47f73b4 commit 0d99de2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions plugins/package-managers/pub/src/main/kotlin/Pubspec.kt
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,17 @@ private class DependencyMapSerializer : KSerializer<Map<String, Dependency>> {
}

override fun deserialize(decoder: Decoder): Map<String, Dependency> {
val node = (decoder.beginStructure(descriptor) as YamlInput).node
val input = decoder.beginStructure(descriptor) as YamlInput

return when (node) {
val result = when (val node = input.node) {
is YamlScalar -> emptyMap()
is YamlMap -> node.entries.asSequence().associateBy({ it.key.content }, { it.value.decodeDependency() })
else -> throw SerializationException("Unexpected YAML node type: ${node.javaClass.simpleName}.")
}

input.endStructure(descriptor)

return result
}

private fun YamlNode.decodeDependency(): Dependency {
Expand Down

0 comments on commit 0d99de2

Please sign in to comment.