-
Notifications
You must be signed in to change notification settings - Fork 22
Closed
scala/scala
#8549Description
Tail for next concatenations can be detached after Iterator ++ ConcatIterator:
scala> var initIt = Array(1).iterator
scala> val concatIt = Array(2).iterator ++ Array(3).iterator
scala> var it = initIt ++ concatIt // (1)
scala> it.next()
res0: Int = 1
scala> it.hasNext // (2)
res1: Boolean = true
scala> it = it ++ Array(4).iterator // (3)
scala> it.next()
res2: Int = 2
scala> it.next()
res3: Int = 3
scala> it.hasNext // (4)
res4: Boolean = false
(1) concatIt is assigned to tail and last link
(2) merge method is called, it unwraps the tail (concatIt), but last field still contains wrapped object link
(3) other Iterator concatenated to current, but it connects to tail of the last field which is already detached from iteration in (2) link
As a result we have false in (4)
This behavior was introduced in #5033
Scala v2.12.10, v2.13.1
Java 1.8.0_212
Reactions are currently unavailable