Skip to content

Commit

Permalink
Fix NPE regression in Vector.prependedAll
Browse files Browse the repository at this point in the history
Also make a corresponding fix to appenededAll. This isn't exercised
by the test case though.
  • Loading branch information
retronym committed Mar 27, 2022
1 parent c8ee991 commit d0554f2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/library/scala/collection/immutable/Vector.scala
Expand Up @@ -193,13 +193,15 @@ sealed abstract class Vector[+A] private[immutable] (private[immutable] final va
override def prepended[B >: A](elem: B): Vector[B] = super.prepended(elem)
override def prependedAll[B >: A](prefix: collection.IterableOnce[B]): Vector[B] = {
val k = prefix.knownSize
if(k == 0) this
if (k == 0) this
else if (k < 0) super.prependedAll(prefix)
else prependedAll0(prefix, k)
}

override final def appendedAll[B >: A](suffix: collection.IterableOnce[B]): Vector[B] = {
val k = suffix.knownSize
if(k == 0) this
if (k == 0) this
else if (k < 0) super.appendedAll(prefix)
else appendedAll0(suffix, k)
}

Expand Down

0 comments on commit d0554f2

Please sign in to comment.