Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,10 @@ abstract class TreeNode[BaseType <: TreeNode[BaseType]] extends Product {
case s: StructType => s // Don't convert struct types to some other type of Seq[StructField]
// Handle Seq[TreeNode] in TreeNode parameters.
case s: Seq[_] => s.map {
case arg: TreeNode[_] if containsChild(arg) =>
case arg: TreeNode[_] if containsChild(arg) && remainingOldChildren.size > 0 =>
val newChild = remainingNewChildren.remove(0)
val oldChild = remainingOldChildren.remove(0)
assert(arg == oldChild)
if (newChild fastEquals oldChild) {
oldChild
} else {
Expand All @@ -214,9 +215,10 @@ abstract class TreeNode[BaseType <: TreeNode[BaseType]] extends Product {
case null => null
}
case m: Map[_, _] => m.mapValues {
case arg: TreeNode[_] if containsChild(arg) =>
case arg: TreeNode[_] if containsChild(arg) && remainingOldChildren.size > 0 =>
val newChild = remainingNewChildren.remove(0)
val oldChild = remainingOldChildren.remove(0)
assert(arg == oldChild)
if (newChild fastEquals oldChild) {
oldChild
} else {
Expand All @@ -226,9 +228,10 @@ abstract class TreeNode[BaseType <: TreeNode[BaseType]] extends Product {
case nonChild: AnyRef => nonChild
case null => null
}.view.force // `mapValues` is lazy and we need to force it to materialize
case arg: TreeNode[_] if containsChild(arg) =>
case arg: TreeNode[_] if containsChild(arg) && remainingOldChildren.size > 0 =>
val newChild = remainingNewChildren.remove(0)
val oldChild = remainingOldChildren.remove(0)
assert(arg == oldChild)
if (newChild fastEquals oldChild) {
oldChild
} else {
Expand Down