diff options
author | Paul Phillips <paulp@improving.org> | 2012-08-17 17:58:20 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-08-17 20:18:28 -0700 |
commit | 823239f347dd516214a64d755f0d09e9e0321d9c (patch) | |
tree | cea9efc16ac6aff4fabfc58c28b825bd22aac358 /src/library/scala/collection/generic | |
parent | 0fc0038e33b629efcaa0aa314b0e69419c116777 (diff) | |
download | scala-823239f347dd516214a64d755f0d09e9e0321d9c.tar.gz scala-823239f347dd516214a64d755f0d09e9e0321d9c.tar.bz2 scala-823239f347dd516214a64d755f0d09e9e0321d9c.zip |
Modified SI-6150 fix again.
Have to keep a sharp eye on those ReusableCBFs.
Now all the indexed sequences should be using the
same instance.
Diffstat (limited to 'src/library/scala/collection/generic')
-rw-r--r-- | src/library/scala/collection/generic/GenTraversableFactory.scala | 6 | ||||
-rw-r--r-- | src/library/scala/collection/generic/IndexedSeqFactory.scala | 21 |
2 files changed, 23 insertions, 4 deletions
diff --git a/src/library/scala/collection/generic/GenTraversableFactory.scala b/src/library/scala/collection/generic/GenTraversableFactory.scala index 076f555506..6614dbdc62 100644 --- a/src/library/scala/collection/generic/GenTraversableFactory.scala +++ b/src/library/scala/collection/generic/GenTraversableFactory.scala @@ -38,11 +38,10 @@ import language.higherKinds abstract class GenTraversableFactory[CC[X] <: GenTraversable[X] with GenericTraversableTemplate[X, CC]] extends GenericCompanion[CC] { - // A default implementation of GenericCanBuildFrom which can be cast - // to whatever is desired. - val ReusableCBF: GenericCanBuildFrom[Nothing] = new GenericCanBuildFrom[Nothing] { + private[this] val ReusableCBFInstance: GenericCanBuildFrom[Nothing] = new GenericCanBuildFrom[Nothing] { override def apply() = newBuilder[Nothing] } + def ReusableCBF: GenericCanBuildFrom[Nothing] = ReusableCBFInstance /** A generic implementation of the `CanBuildFrom` trait, which forwards * all calls to `apply(from)` to the `genericBuilder` method of @@ -250,4 +249,3 @@ abstract class GenTraversableFactory[CC[X] <: GenTraversable[X] with GenericTrav b.result } } - diff --git a/src/library/scala/collection/generic/IndexedSeqFactory.scala b/src/library/scala/collection/generic/IndexedSeqFactory.scala new file mode 100644 index 0000000000..e5162c640b --- /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.8 + */ +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]] +} |