diff --git a/compat/src/main/scala-2.11_2.12/scala/collection/compat/BuildFrom.scala b/compat/src/main/scala-2.11_2.12/scala/collection/compat/BuildFrom.scala index c03033bd..cb80484a 100644 --- a/compat/src/main/scala-2.11_2.12/scala/collection/compat/BuildFrom.scala +++ b/compat/src/main/scala-2.11_2.12/scala/collection/compat/BuildFrom.scala @@ -13,7 +13,7 @@ package scala.collection.compat import scala.collection.generic.CanBuildFrom -import scala.collection.{Iterable, mutable} +import scala.collection.mutable /** Builds a collection of type `C` from elements of type `A` when a source collection of type `From` is available. * Implicit instances of `BuildFrom` are available for all collection types. @@ -23,16 +23,14 @@ import scala.collection.{Iterable, mutable} * @tparam C Type of collection (e.g. `List[Int]`, `TreeMap[Int, String]`, etc.) */ trait BuildFrom[-From, -A, +C] extends Any { - - def fromSpecificIterable(from: From)(it: Iterable[A]): C + def fromSpecific(from: From)(it: IterableOnce[A]): C /** Get a Builder for the collection. For non-strict collection types this will use an intermediate buffer. - * Building collections with `fromSpecificIterable` is preferred because it can be lazy for lazy collections. */ + * Building collections with `fromSpecific` is preferred because it can be lazy for lazy collections. */ def newBuilder(from: From): mutable.Builder[A, C] - @deprecated("Use newBuilder instead of apply()", "2.13.0") + @deprecated("Use newBuilder() instead of apply()", "2.13.0") @`inline` def apply(from: From): mutable.Builder[A, C] = newBuilder(from) - } object BuildFrom { @@ -41,7 +39,7 @@ object BuildFrom { implicit def fromCanBuildFrom[From, A, C]( implicit cbf: CanBuildFrom[From, A, C]): BuildFrom[From, A, C] = new BuildFrom[From, A, C] { - def fromSpecificIterable(from: From)(it: Iterable[A]): C = (cbf(from) ++= it).result() + def fromSpecific(from: From)(it: IterableOnce[A]): C = (cbf(from) ++= it).result() def newBuilder(from: From): mutable.Builder[A, C] = cbf(from) } diff --git a/compat/src/test/scala/test/scala/collection/BuildFromTest.scala b/compat/src/test/scala/test/scala/collection/BuildFromTest.scala index 0081eb05..4e766a17 100644 --- a/compat/src/test/scala/test/scala/collection/BuildFromTest.scala +++ b/compat/src/test/scala/test/scala/collection/BuildFromTest.scala @@ -158,4 +158,10 @@ class BuildFromTest { Map: BuildFrom[_, (Int, String), Map[Int, String]] SortedSet: BuildFrom[_, Int, SortedSet[Int]] SortedMap: BuildFrom[_, (Int, String), SortedMap[Int, String]] + + // Implement BuildFrom + class MyBuildFrom[From, A, C] extends BuildFrom[From, A, C] { + def fromSpecific(from: From)(it: IterableOnce[A]): C = ??? + def newBuilder(from: From): Builder[A, C] = ??? + } }