diff --git a/compat/src/main/scala-2.11_2.12/scala/collection/compat/immutable/ArraySeq.scala b/compat/src/main/scala-2.11_2.12/scala/collection/compat/immutable/ArraySeq.scala index 5dcb4e9f..ff299818 100644 --- a/compat/src/main/scala-2.11_2.12/scala/collection/compat/immutable/ArraySeq.scala +++ b/compat/src/main/scala-2.11_2.12/scala/collection/compat/immutable/ArraySeq.scala @@ -58,7 +58,7 @@ abstract class ArraySeq[+T] extends AbstractSeq[T] with IndexedSeq[T] { /** Creates new builder for this collection ==> move to subclasses */ override protected[this] def newBuilder: Builder[T, ArraySeq[T]] = - new WrappedArrayBuilder[T](elemTag).mapResult(w => ArraySeq.unsafeWrapArray(w.array)) + ArraySeq.newBuilder[T](elemTag) } @@ -69,6 +69,17 @@ object ArraySeq { private val EmptyArraySeq = new ofRef[AnyRef](new Array[AnyRef](0)) def empty[T <: AnyRef]: ArraySeq[T] = EmptyArraySeq.asInstanceOf[ArraySeq[T]] + def newBuilder[T](implicit elemTag: ClassTag[T]): Builder[T, ArraySeq[T]] = + new WrappedArrayBuilder[T](elemTag).mapResult(w => unsafeWrapArray(w.array)) + + def apply[T](elems: T*)(implicit elemTag: ClassTag[T]): ArraySeq[T] = { + val b = newBuilder[T] + b ++= elems + b.result() + } + + def unapplySeq[T](seq: ArraySeq[T]): Some[ArraySeq[T]] = Some(seq) + /** * Wrap an existing `Array` into an `ArraySeq` of the proper primitive specialization type * without copying.