Skip to content

Commit

Permalink
implement List merge
Browse files Browse the repository at this point in the history
  • Loading branch information
martinbonnin committed Jan 12, 2021
1 parent a950b6f commit 5654c19
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@ fun NormalizationIR.Element.mergeWith(other: NormalizationIR.Element): Normaliza
check(this.value == other.value)
this
}
this is NormalizationIR.Element.List && other is NormalizationIR.Element.List -> throw UnsupportedOperationException()
this is NormalizationIR.Element.List && other is NormalizationIR.Element.List -> {
check(this.elements.size == other.elements.size)

NormalizationIR.Element.List(
elements = elements.mapIndexed { index, element ->
element.mergeWith(other.elements[index])
}
)
}
this is NormalizationIR.Element.Object && other is NormalizationIR.Element.Object -> {
val newFields = fields.toMutableList()

Expand Down

0 comments on commit 5654c19

Please sign in to comment.