Skip to content

Commit ae7f589

Browse files
committed
Drop StrictIterableFactory in favor of caps.Pure constraints
1 parent 839c37e commit ae7f589

File tree

1 file changed

+3
-43
lines changed

1 file changed

+3
-43
lines changed

library/src/scala/collection/Factory.scala

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -293,57 +293,17 @@ object IterableFactory {
293293
}
294294
}
295295

296-
/** IterableFactory but with strict operations that do not capture the inputs. */
297-
trait StrictIterableFactory[+CC[_] <: caps.Pure] extends IterableFactory[CC] {
298-
// pure overrides of the IterableFactory methods
299-
override def from[A](source: IterableOnce[A]^): CC[A]
300-
301-
override def iterate[A](start: A, len: Int)(f: A => A): CC[A] = from(new View.Iterate(start, len)(f))
302-
303-
override def unfold[A, S](init: S)(f: S => Option[(A, S)]): CC[A] = from(new View.Unfold(init)(f))
304-
305-
override def fill[A](n: Int)(elem: => A): CC[A] = from(new View.Fill(n)(elem))
306-
307-
override def fill[A](n1: Int, n2: Int)(elem: => A): CC[CC[A] @uncheckedVariance] = fill(n1)(fill(n2)(elem))
308-
309-
override def fill[A](n1: Int, n2: Int, n3: Int)(elem: => A): CC[CC[CC[A]] @uncheckedVariance] = fill(n1)(fill(n2, n3)(elem))
310-
311-
override def fill[A](n1: Int, n2: Int, n3: Int, n4: Int)(elem: => A): CC[CC[CC[CC[A]]] @uncheckedVariance] =
312-
fill(n1)(fill(n2, n3, n4)(elem))
313-
314-
override def fill[A](n1: Int, n2: Int, n3: Int, n4: Int, n5: Int)(elem: => A): CC[CC[CC[CC[CC[A]]]] @uncheckedVariance] =
315-
fill(n1)(fill(n2, n3, n4, n5)(elem))
316-
317-
override def tabulate[A](n: Int)(f: Int => A): CC[A] = from(new View.Tabulate(n)(f))
318-
319-
override def tabulate[A](n1: Int, n2: Int)(f: (Int, Int) => A): CC[CC[A] @uncheckedVariance] =
320-
tabulate(n1)(i1 => tabulate(n2)(f(i1, _)))
321-
322-
override def tabulate[A](n1: Int, n2: Int, n3: Int)(f: (Int, Int, Int) => A): CC[CC[CC[A]] @uncheckedVariance] =
323-
tabulate(n1)(i1 => tabulate(n2, n3)(f(i1, _, _)))
324-
325-
override def tabulate[A](n1: Int, n2: Int, n3: Int, n4: Int)(f: (Int, Int, Int, Int) => A): CC[CC[CC[CC[A]]] @uncheckedVariance] =
326-
tabulate(n1)(i1 => tabulate(n2, n3, n4)(f(i1, _, _, _)))
327-
328-
override def tabulate[A](n1: Int, n2: Int, n3: Int, n4: Int, n5: Int)(f: (Int, Int, Int, Int, Int) => A): CC[CC[CC[CC[CC[A]]]] @uncheckedVariance] =
329-
tabulate(n1)(i1 => tabulate(n2, n3, n4, n5)(f(i1, _, _, _, _)))
330-
331-
override def concat[A](xss: Iterable[A]*): CC[A] = {
332-
from(xss.foldLeft(View.empty[A])(_ ++ _))
333-
}
334-
}
335-
336296
/**
337297
* @tparam CC Collection type constructor (e.g. `List`)
338298
*/
339-
trait SeqFactory[+CC[A] <: StrictSeqOps[A, Seq, Seq[A]]] extends StrictIterableFactory[CC] {
299+
trait SeqFactory[+CC[A] <: SeqOps[A, Seq, Seq[A]] & caps.Pure] extends IterableFactory[CC] {
340300
import SeqFactory.UnapplySeqWrapper
341301
final def unapplySeq[A](x: CC[A] @uncheckedVariance): UnapplySeqWrapper[A] = new UnapplySeqWrapper(x) // TODO is uncheckedVariance sound here?
342302
}
343303

344304
object SeqFactory {
345305
@SerialVersionUID(3L)
346-
class Delegate[CC[A] <: StrictSeqOps[A, Seq, Seq[A]]](delegate: SeqFactory[CC]) extends SeqFactory[CC] {
306+
class Delegate[CC[A] <: SeqOps[A, Seq, Seq[A]] & caps.Pure](delegate: SeqFactory[CC]) extends SeqFactory[CC] {
347307
override def apply[A](elems: A*): CC[A] = delegate.apply(elems: _*)
348308
def empty[A]: CC[A] = delegate.empty
349309
def from[E](it: IterableOnce[E]^): CC[E] = delegate.from(it)
@@ -363,7 +323,7 @@ object SeqFactory {
363323
}
364324
}
365325

366-
trait StrictOptimizedSeqFactory[+CC[A] <: StrictSeqOps[A, Seq, Seq[A]]] extends SeqFactory[CC] {
326+
trait StrictOptimizedSeqFactory[+CC[A] <: SeqOps[A, Seq, Seq[A]] & caps.Pure] extends SeqFactory[CC] {
367327

368328
override def fill[A](n: Int)(elem: => A): CC[A] = {
369329
val b = newBuilder[A]

0 commit comments

Comments
 (0)