Skip to content

Commit 84dd46c

Browse files
authored
Merge pull request scala/scala#7150 from xuwei-k/IterableOnce-deprecated-methods
fix warnings. avoid IterableOnce deprecated methods
2 parents b28bb06 + 76c7a54 commit 84dd46c

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

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

Lines changed: 2 additions & 2 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,7 +202,7 @@ 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 {
207207
prefix.size match {
208208
case n if n <= TinyAppendFaster || n < (this.size >>> Log2ConcatFaster) =>

library/src/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

library/src/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

library/src/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)