Skip to content

Commit 8232eea

Browse files
authored
Merge pull request scala/scala#10416 from lrytz/t12796
Fix ListBuffer.insertAfter, used in patchInPlace
2 parents 20a42f6 + 36fde5d commit 8232eea

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

library/src/scala/collection/mutable/ListBuffer.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ListBuffer[A]
4646
@transient private[this] var mutationCount: Int = 0
4747

4848
private var first: List[A] = Nil
49-
private var last0: ::[A] = null
49+
private var last0: ::[A] = null // last element (`last0` just because the name `last` is already taken)
5050
private[this] var aliased = false
5151
private[this] var len = 0
5252

@@ -244,6 +244,7 @@ class ListBuffer[A]
244244
val follow = getNext(prev)
245245
if (prev eq null) first = fresh.first else prev.next = fresh.first
246246
fresh.last0.next = follow
247+
if (follow.isEmpty) last0 = fresh.last0
247248
len += fresh.length
248249
}
249250
}

0 commit comments

Comments
 (0)