Skip to content

Commit 167fdb5

Browse files
authored
Merge pull request scala/scala#7153 from xuwei-k/Vector-prependedAll
fix scala/scala#11122 Vector#prependedAll
2 parents 84dd46c + 3ce9bb1 commit 167fdb5

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

library/src/scala/collection/immutable/Vector.scala

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -204,18 +204,23 @@ final class Vector[+A] private[immutable] (private[collection] val startIndex: I
204204
import Vector.{Log2ConcatFaster, TinyAppendFaster}
205205
if (prefix.iterator.isEmpty) this
206206
else {
207-
prefix.size match {
208-
case n if n <= TinyAppendFaster || n < (this.size >>> Log2ConcatFaster) =>
209-
var v: Vector[B] = this
210-
val it = prefix.toIndexedSeq.reverseIterator
211-
while (it.hasNext) v = it.next() +: v
212-
v
213-
case n if this.size < (n >>> Log2ConcatFaster) && prefix.isInstanceOf[Vector[_]] =>
214-
var v = prefix.asInstanceOf[Vector[B]]
215-
val it = this.iterator
216-
while (it.hasNext) v = v :+ it.next()
217-
v
218-
case _ => super.prependedAll(prefix)
207+
prefix match {
208+
case prefix: collection.Iterable[B] =>
209+
prefix.size match {
210+
case n if n <= TinyAppendFaster || n < (this.size >>> Log2ConcatFaster) =>
211+
var v: Vector[B] = this
212+
val it = prefix.toIndexedSeq.reverseIterator
213+
while (it.hasNext) v = it.next() +: v
214+
v
215+
case n if this.size < (n >>> Log2ConcatFaster) && prefix.isInstanceOf[Vector[_]] =>
216+
var v = prefix.asInstanceOf[Vector[B]]
217+
val it = this.iterator
218+
while (it.hasNext) v = v :+ it.next()
219+
v
220+
case _ => super.prependedAll(prefix)
221+
}
222+
case _ =>
223+
super.prependedAll(prefix)
219224
}
220225
}
221226
}

0 commit comments

Comments
 (0)