diff options
author | Paul Phillips <paulp@improving.org> | 2011-05-14 16:54:42 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-05-14 16:54:42 +0000 |
commit | c989273edb4302762ac41cb799862cd2f4c8fcc8 (patch) | |
tree | 1956b60bb4497d9c32512b2f689d99b7d154e189 /src/library | |
parent | 48e96634892328aa2c2cf4a85fd67edaa3e5aeed (diff) | |
download | scala-c989273edb4302762ac41cb799862cd2f4c8fcc8.tar.gz scala-c989273edb4302762ac41cb799862cd2f4c8fcc8.tar.bz2 scala-c989273edb4302762ac41cb799862cd2f4c8fcc8.zip |
Fix for view+groupBy closes #4558, no review.
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/collection/TraversableViewLike.scala | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/library/scala/collection/TraversableViewLike.scala b/src/library/scala/collection/TraversableViewLike.scala index 6dc0936c61..23e967aea0 100644 --- a/src/library/scala/collection/TraversableViewLike.scala +++ b/src/library/scala/collection/TraversableViewLike.scala @@ -16,6 +16,8 @@ import annotation.migration trait ViewMkString[+A] { self: Traversable[A] => + // It is necessary to use thisSeq rather than toSeq to avoid cycles in the + // eager evaluation of vals in transformed view subclasses, see #4558. protected[this] def thisSeq: Seq[A] = new ArrayBuffer[A] ++= self result // Have to overload all three to work around #4299. The overload @@ -157,17 +159,17 @@ trait TraversableViewLike[+A, override def splitAt(n: Int): (This, This) = (newTaken(n), newDropped(n)) override def scanLeft[B, That](z: B)(op: (B, A) => B)(implicit bf: CanBuildFrom[This, B, That]): That = - newForced(self.toSeq.scanLeft(z)(op)).asInstanceOf[That] + newForced(thisSeq.scanLeft(z)(op)).asInstanceOf[That] @migration(2, 9, "This scanRight definition has changed in 2.9.\n" + "The previous behavior can be reproduced with scanRight.reverse." ) override def scanRight[B, That](z: B)(op: (A, B) => B)(implicit bf: CanBuildFrom[This, B, That]): That = - newForced(self.toSeq.scanRight(z)(op)).asInstanceOf[That] + newForced(thisSeq.scanRight(z)(op)).asInstanceOf[That] override def groupBy[K](f: A => K): immutable.Map[K, This] = - self.toSeq.groupBy(f).mapValues(xs => newForced(xs).asInstanceOf[This]) + thisSeq.groupBy(f).mapValues(xs => newForced(thisSeq)) override def toString = viewToString } |