summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/generic
diff options
context:
space:
mode:
authorAleksandar Prokopec <axel22@gmail.com>2012-11-14 20:42:24 +0100
committerAleksandar Prokopec <axel22@gmail.com>2012-11-14 20:42:24 +0100
commit1f0e4880ad7ad816fd82c04f6814c5b165f86981 (patch)
tree2d0368d361dbd207fcb7c3bc1d29dd7f57d1f788 /src/library/scala/collection/generic
parent850108886765e99e894f7613f49c1bab3650a0c2 (diff)
downloadscala-1f0e4880ad7ad816fd82c04f6814c5b165f86981.tar.gz
scala-1f0e4880ad7ad816fd82c04f6814c5b165f86981.tar.bz2
scala-1f0e4880ad7ad816fd82c04f6814c5b165f86981.zip
Fixes SI-6150 - backport to 2.10.x branch.
Diffstat (limited to 'src/library/scala/collection/generic')
-rw-r--r--src/library/scala/collection/generic/GenTraversableFactory.scala9
-rw-r--r--src/library/scala/collection/generic/IndexedSeqFactory.scala21
2 files changed, 24 insertions, 6 deletions
diff --git a/src/library/scala/collection/generic/GenTraversableFactory.scala b/src/library/scala/collection/generic/GenTraversableFactory.scala
index d5edf5961e..a43862abaf 100644
--- a/src/library/scala/collection/generic/GenTraversableFactory.scala
+++ b/src/library/scala/collection/generic/GenTraversableFactory.scala
@@ -36,15 +36,12 @@ import scala.language.higherKinds
* @see GenericCanBuildFrom
*/
abstract class GenTraversableFactory[CC[X] <: GenTraversable[X] with GenericTraversableTemplate[X, CC]]
- extends GenericCompanion[CC] {
+extends GenericCompanion[CC] {
- // A default implementation of GenericCanBuildFrom which can be cast
- // to whatever is desired.
- private class ReusableCBF extends GenericCanBuildFrom[Nothing] {
+ private[this] val ReusableCBFInstance: GenericCanBuildFrom[Nothing] = new GenericCanBuildFrom[Nothing] {
override def apply() = newBuilder[Nothing]
}
- // Working around SI-4789 by using a lazy val instead of an object.
- lazy val ReusableCBF: GenericCanBuildFrom[Nothing] = new ReusableCBF
+ def ReusableCBF: GenericCanBuildFrom[Nothing] = ReusableCBFInstance
/** A generic implementation of the `CanBuildFrom` trait, which forwards
* all calls to `apply(from)` to the `genericBuilder` method of
diff --git a/src/library/scala/collection/generic/IndexedSeqFactory.scala b/src/library/scala/collection/generic/IndexedSeqFactory.scala
new file mode 100644
index 0000000000..200d033c2d
--- /dev/null
+++ b/src/library/scala/collection/generic/IndexedSeqFactory.scala
@@ -0,0 +1,21 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+package scala.collection
+package generic
+
+import language.higherKinds
+
+/** A template for companion objects of IndexedSeq and subclasses thereof.
+ *
+ * @since 2.10
+ */
+abstract class IndexedSeqFactory[CC[X] <: IndexedSeq[X] with GenericTraversableTemplate[X, CC]] extends SeqFactory[CC] {
+ override def ReusableCBF: GenericCanBuildFrom[Nothing] =
+ scala.collection.IndexedSeq.ReusableCBF.asInstanceOf[GenericCanBuildFrom[Nothing]]
+}