diff options
author | Rex Kerr <ichoran@gmail.com> | 2015-02-18 18:52:46 -0800 |
---|---|---|
committer | Rex Kerr <ichoran@gmail.com> | 2015-02-20 00:07:44 -0800 |
commit | 1d4a1f721d360c73b9f2468368c7e9b2b4c17fea (patch) | |
tree | 9cd0a2db1374c03934adde0483f43dd96cac235a /src/library | |
parent | 18870094f2464e39067baeea71c4ae7ab8dfc6d9 (diff) | |
download | scala-1d4a1f721d360c73b9f2468368c7e9b2b4c17fea.tar.gz scala-1d4a1f721d360c73b9f2468368c7e9b2b4c17fea.tar.bz2 scala-1d4a1f721d360c73b9f2468368c7e9b2b4c17fea.zip |
SI-9126 Missing .seqs causes problems with parallel GenXs
Added `.seq` in two essential places so that a parallel collection passed as an argument won't mess up side-effecting sequential computations in `List.flatMap` and `GenericTraversableTemplate.transpose` (thanks to retronym for finding the danger spots).
Tests that `.seq` is called by constructing a `GenSeq` whose `.seq` disagrees with anything non-`.seq` (idea & working implementation from retronym).
Also updates the `.seq` test for `Vector#++` to use the new more efficient method.
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/collection/generic/GenericTraversableTemplate.scala | 2 | ||||
-rw-r--r-- | src/library/scala/collection/immutable/List.scala | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/library/scala/collection/generic/GenericTraversableTemplate.scala b/src/library/scala/collection/generic/GenericTraversableTemplate.scala index 54455c531a..bdd91ba7a4 100644 --- a/src/library/scala/collection/generic/GenericTraversableTemplate.scala +++ b/src/library/scala/collection/generic/GenericTraversableTemplate.scala @@ -216,7 +216,7 @@ trait GenericTraversableTemplate[+A, +CC[X] <: GenTraversable[X]] extends HasNew val bs: IndexedSeq[Builder[B, CC[B]]] = IndexedSeq.fill(headSize)(genericBuilder[B]) for (xs <- sequential) { var i = 0 - for (x <- asTraversable(xs)) { + for (x <- asTraversable(xs).seq) { if (i >= headSize) fail bs(i) += x i += 1 diff --git a/src/library/scala/collection/immutable/List.scala b/src/library/scala/collection/immutable/List.scala index a46b4adabb..254f14f13c 100644 --- a/src/library/scala/collection/immutable/List.scala +++ b/src/library/scala/collection/immutable/List.scala @@ -324,7 +324,7 @@ sealed abstract class List[+A] extends AbstractSeq[A] var h: ::[B] = null var t: ::[B] = null while (rest ne Nil) { - f(rest.head).foreach{ b => + f(rest.head).seq.foreach{ b => if (!found) { h = new ::(b, Nil) t = h |