Skip to content

Commit 4b8be45

Browse files
committed
fix struct member indexes
1 parent 5ff9159 commit 4b8be45

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

compiler/lib/src/main/scala/codegen/DictionaryJsonWriter/DictionaryJsonEncoder.scala

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -237,26 +237,25 @@ case class DictionaryJsonEncoder(
237237
jsonWithOptionalValues(json, optionalValues)
238238
}
239239
case Symbol.Struct(preA, node, postA) => {
240-
val Type.Struct(_, anonStruct, default, sizes, formats) = dictionaryState.a.typeMap(symbol.getNodeId)
241-
val Type.AnonStruct(members) = anonStruct
240+
val Type.Struct(_, _, default, sizes, _) = dictionaryState.a.typeMap(symbol.getNodeId)
242241
val memberFormatMap = node.data.members.flatMap { case (_, memberNode, _) =>
243242
memberNode.data.format.map(format => memberNode.data.name -> format.data)
244243
}.toMap
245244
val memberAnnotationMap = node.data.members.flatMap { case (preA, memberNode, postA) =>
246245
val annotation = (preA ++ postA).mkString("\n")
247246
if (annotation.isEmpty) None else Some(memberNode.data.name -> annotation)
248247
}.toMap
249-
val membersFormatted = for(((key, t), index) <- members.zipWithIndex) yield {
248+
val membersFormatted = for(((_, m, _), index) <- node.data.members.zipWithIndex) yield {
250249
val json = Json.obj(
251-
"type" -> typeAsJson(t).asJson,
250+
"type" -> typeAsJson(dictionaryState.a.typeMap(m.data.typeName.id)),
252251
"index" -> index.asJson
253252
)
254253
val optionalValues = Map(
255-
"size" -> sizes.get(key),
256-
"format" -> memberFormatMap.get(key),
257-
"annotation" -> memberAnnotationMap.get(key)
254+
"size" -> sizes.get(m.data.name),
255+
"format" -> memberFormatMap.get(m.data.name),
256+
"annotation" -> memberAnnotationMap.get(m.data.name)
258257
)
259-
(key.toString -> jsonWithOptionalValues(json, optionalValues))
258+
(m.data.name.toString -> jsonWithOptionalValues(json, optionalValues))
260259
}
261260
val json = Json.obj(
262261
"kind" -> "struct".asJson,
@@ -550,4 +549,4 @@ case class DictionaryJsonEncoder(
550549
}
551550
}
552551

553-
}
552+
}

0 commit comments

Comments
 (0)