Skip to content

Commit 88148c6

Browse files
committed
fix warnings. avoid IterableOnce deprecated methods
1 parent 4bfe574 commit 88148c6

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

src/library/scala/collection/immutable/LazyList.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ final class LazyList[+A] private(private[this] var lazyState: () => LazyList.Sta
351351

352352
override def prependedAll[B >: A](prefix: scala.IterableOnce[B]): LazyList[B] =
353353
newLL {
354-
if (prefix.isEmpty) state
354+
if (prefix.iterator.isEmpty) state
355355
else stateFromIteratorConcatSuffix(prefix.iterator)(state)
356356
}
357357

@@ -396,7 +396,7 @@ final class LazyList[+A] private(private[this] var lazyState: () => LazyList.Sta
396396

397397
override def zip[B](that: collection.IterableOnce[B]): LazyList[(A, B)] =
398398
newLL {
399-
if (this.isEmpty || that.isEmpty) State.Empty
399+
if (this.isEmpty || that.iterator.isEmpty) State.Empty
400400
else {
401401
val thatIterable = that match {
402402
case that: collection.Iterable[B] => that

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ final class Vector[+A] private[immutable] (private[collection] val startIndex: I
176176
// appendAll (suboptimal but avoids worst performance gotchas)
177177
override def appendedAll[B >: A](suffix: collection.IterableOnce[B]): Vector[B] = {
178178
import Vector.{Log2ConcatFaster, TinyAppendFaster}
179-
if (suffix.isEmpty) this
179+
if (suffix.iterator.isEmpty) this
180180
else {
181181
suffix match {
182182
case suffix: collection.Iterable[B] =>
@@ -202,12 +202,12 @@ final class Vector[+A] private[immutable] (private[collection] val startIndex: I
202202
// Implementation similar to `appendAll`: when of the collections to concatenate (either `this` or `prefix`)
203203
// has a small number of elements compared to the other, then we add them using `:+` or `+:` in a loop
204204
import Vector.{Log2ConcatFaster, TinyAppendFaster}
205-
if (prefix.isEmpty) this
205+
if (prefix.iterator.isEmpty) this
206206
else {
207-
prefix.size match {
207+
prefix.iterator.size match {
208208
case n if n <= TinyAppendFaster || n < (this.size >>> Log2ConcatFaster) =>
209209
var v: Vector[B] = this
210-
val it = prefix.toIndexedSeq.reverseIterator
210+
val it = prefix.iterator.toIndexedSeq.reverseIterator
211211
while (it.hasNext) v = it.next() +: v
212212
v
213213
case n if this.size < (n >>> Log2ConcatFaster) && prefix.isInstanceOf[Vector[_]] =>

src/library/scala/collection/mutable/AnyRefMap.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class AnyRefMap[K <: AnyRef, V] private[collection] (defaultEntry: K => V, initi
7979
var sz = coll.knownSize
8080
if(sz < 0) sz = 4
8181
val arm = new AnyRefMap[K, V](sz * 2)
82-
coll.foreach{ case (k,v) => arm(k) = v }
82+
coll.iterator.foreach{ case (k,v) => arm(k) = v }
8383
if (arm.size < (sz>>3)) arm.repack()
8484
arm
8585
}
@@ -375,7 +375,7 @@ class AnyRefMap[K <: AnyRef, V] private[collection] (defaultEntry: K => V, initi
375375

376376
override def concat[V2 >: V](xs: scala.collection.IterableOnce[(K, V2)]): AnyRefMap[K, V2] = {
377377
val arm = clone().asInstanceOf[AnyRefMap[K, V2]]
378-
xs.foreach(kv => arm += kv)
378+
xs.iterator.foreach(kv => arm += kv)
379379
arm
380380
}
381381

src/library/scala/collection/mutable/LongMap.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ final class LongMap[V] private[collection] (defaultEntry: Long => V, initialBuff
446446

447447
override def concat[V1 >: V](xs: scala.collection.IterableOnce[(Long, V1)]): LongMap[V1] = {
448448
val lm = clone().asInstanceOf[LongMap[V1]]
449-
xs.foreach(kv => lm += kv)
449+
xs.iterator.foreach(kv => lm += kv)
450450
lm
451451
}
452452

src/library/scala/concurrent/Future.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ object Future {
688688
* @return the `Future` of the resulting collection
689689
*/
690690
final def sequence[A, CC[X] <: IterableOnce[X], To](in: CC[Future[A]])(implicit bf: BuildFrom[CC[Future[A]], A, To], executor: ExecutionContext): Future[To] =
691-
in.foldLeft(successful(bf.newBuilder(in))) {
691+
in.iterator.foldLeft(successful(bf.newBuilder(in))) {
692692
(fr, fa) => fr.zipWith(fa)(Future.addToBuilderFun)
693693
}.map(_.result())(InternalCallbackExecutor)
694694

@@ -700,7 +700,7 @@ object Future {
700700
* @return the `Future` holding the result of the future that is first to be completed
701701
*/
702702
final def firstCompletedOf[T](futures: IterableOnce[Future[T]])(implicit executor: ExecutionContext): Future[T] =
703-
if (futures.isEmpty) Future.never
703+
if (futures.iterator.isEmpty) Future.never
704704
else {
705705
val p = Promise[T]()
706706
val firstCompleteHandler = new AtomicReference[Promise[T]](p) with (Try[T] => Unit) {
@@ -837,7 +837,7 @@ object Future {
837837
* @return the `Future` of the `IterableOnce` of results
838838
*/
839839
final def traverse[A, B, M[X] <: IterableOnce[X]](in: M[A])(fn: A => Future[B])(implicit bf: BuildFrom[M[A], B, M[B]], executor: ExecutionContext): Future[M[B]] =
840-
in.foldLeft(successful(bf.newBuilder(in))) {
840+
in.iterator.foldLeft(successful(bf.newBuilder(in))) {
841841
(fr, a) => fr.zipWith(fn(a))(Future.addToBuilderFun)
842842
}.map(_.result())(InternalCallbackExecutor)
843843

0 commit comments

Comments
 (0)