Skip to content

Commit 5ef1606

Browse files
committed
Drop StrictSeqOps and StrictIndexedSeqOps
Inline them into (Indexed)SeqOps and caps.Pure
1 parent ae7f589 commit 5ef1606

File tree

11 files changed

+26
-35
lines changed

11 files changed

+26
-35
lines changed

library/src/scala/collection/Factory.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ object ClassTagSeqFactory {
707707
/** A SeqFactory that uses ClassTag.Any as the evidence for every element type. This may or may not be
708708
* sound depending on the use of the `ClassTag` by the collection implementation. */
709709
@SerialVersionUID(3L)
710-
class AnySeqDelegate[CC[A] <: StrictSeqOps[A, Seq, Seq[A]]](delegate: ClassTagSeqFactory[CC])
710+
class AnySeqDelegate[CC[A] <: SeqOps[A, Seq, Seq[A]] & caps.Pure](delegate: ClassTagSeqFactory[CC])
711711
extends ClassTagIterableFactory.AnyIterableDelegate[CC](delegate) with SeqFactory[CC]
712712
}
713713

library/src/scala/collection/IndexedSeq.scala

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ import scala.math.Ordering
2323

2424
/** Base trait for indexed sequences that have efficient `apply` and `length` */
2525
trait IndexedSeq[+A] extends Seq[A]
26-
with StrictIndexedSeqOps[A, IndexedSeq, IndexedSeq[A]]
27-
with IterableFactoryDefaults[A, IndexedSeq] {
26+
with IndexedSeqOps[A, IndexedSeq, IndexedSeq[A]]
27+
with IterableFactoryDefaults[A, IndexedSeq]
28+
with caps.Pure {
2829
@nowarn("""cat=deprecation&origin=scala\.collection\.Iterable\.stringPrefix""")
2930
override protected[this] def stringPrefix: String = "IndexedSeq"
3031

@@ -34,15 +35,6 @@ trait IndexedSeq[+A] extends Seq[A]
3435
@SerialVersionUID(3L)
3536
object IndexedSeq extends SeqFactory.Delegate[IndexedSeq](immutable.IndexedSeq)
3637

37-
transparent trait StrictIndexedSeqOps[+A, +CC[_] <: caps.Pure, +C] extends Any with StrictSeqOps[A, CC, C] with IndexedSeqOps[A, CC, C] {
38-
override def map[B](f: A => B): CC[B] = iterableFactory.from(new IndexedSeqView.Map(this, f))
39-
override def sliding(size: Int, step: Int): Iterator[C] = {
40-
require(size >= 1 && step >= 1, f"size=$size%d and step=$step%d, but both must be positive")
41-
val it = new IndexedSeqSlidingIterator[A, CC, C](this, size, step)
42-
it.asInstanceOf[Iterator[C]] // TODO: seems like CC cannot figure this out yet
43-
}
44-
}
45-
4638
/** Base trait for indexed Seq operations */
4739
transparent trait IndexedSeqOps[+A, +CC[_], +C] extends Any with SeqOps[A, CC, C] { self: IndexedSeqOps[A, CC, C]^ =>
4840

library/src/scala/collection/LinearSeq.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ trait LinearSeq[+A] extends Seq[A]
3535
object LinearSeq extends SeqFactory.Delegate[LinearSeq](immutable.LinearSeq)
3636

3737
/** Base trait for linear Seq operations */
38-
transparent trait LinearSeqOps[+A, +CC[X] <: LinearSeq[X], +C <: LinearSeq[A] with LinearSeqOps[A, CC, C]] extends Any with StrictSeqOps[A, CC, C] { self =>
38+
transparent trait LinearSeqOps[+A, +CC[X] <: LinearSeq[X], +C <: LinearSeq[A] with LinearSeqOps[A, CC, C]] extends Any with SeqOps[A, CC, C] with caps.Pure { self =>
3939

4040
/** @inheritdoc
4141
*

library/src/scala/collection/Seq.scala

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import scala.annotation.nowarn
2727
trait Seq[+A]
2828
extends Iterable[A]
2929
with PartialFunction[Int, A]
30-
with StrictSeqOps[A, Seq, Seq[A]]
30+
with SeqOps[A, Seq, Seq[A]]
3131
with IterableFactoryDefaults[A, Seq]
3232
with Equals
3333
with caps.Pure {
@@ -58,13 +58,6 @@ trait Seq[+A]
5858
@SerialVersionUID(3L)
5959
object Seq extends SeqFactory.Delegate[Seq](immutable.Seq)
6060

61-
/** Base trait for strict Seq operations.
62-
*
63-
* Contains strict overrides of SeqOps operations, where the parameters are also captured.
64-
*/
65-
transparent trait StrictSeqOps[+A, +CC[B] <: caps.Pure, +C] extends Any with SeqOps[A, CC, C] with caps.Pure {
66-
}
67-
6861
/** Base trait for Seq operations
6962
*
7063
* @tparam A the element type of the collection

library/src/scala/collection/StrictOptimizedSeqOps.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import language.experimental.captureChecking
2020
* to take advantage of strict builders.
2121
*/
2222
transparent trait StrictOptimizedSeqOps [+A, +CC[_] <: caps.Pure, +C]
23-
extends Any with StrictSeqOps[A, CC, C] with StrictOptimizedIterableOps[A, CC, C] {
23+
extends Any with SeqOps[A, CC, C] with StrictOptimizedIterableOps[A, CC, C] with caps.Pure {
2424

2525
override def distinctBy[B](f: A -> B): C = {
2626
val builder = newSpecificBuilder

library/src/scala/collection/immutable/ArraySeq.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ sealed abstract class ArraySeq[+A]
4141
with IndexedSeqOps[A, ArraySeq, ArraySeq[A]]
4242
with StrictOptimizedSeqOps[A, ArraySeq, ArraySeq[A]]
4343
with EvidenceIterableFactoryDefaults[A, ArraySeq, ClassTag]
44-
with Serializable {
44+
with Serializable
45+
with caps.Pure {
4546

4647
/** The tag of the element type. This does not have to be equal to the element type of this ArraySeq. A primitive
4748
* ArraySeq can be backed by an array of boxed values and a reference ArraySeq can be backed by an array of a supertype

library/src/scala/collection/immutable/Seq.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ trait Seq[+A] extends Iterable[A]
3131
* @define coll immutable sequence
3232
* @define Coll `immutable.Seq`
3333
*/
34-
transparent trait SeqOps[+A, +CC[B] <: collection.StrictSeqOps[B, collection.Seq, collection.Seq[B]], +C] extends Any with collection.StrictSeqOps[A, CC, C]
34+
transparent trait SeqOps[+A, +CC[B] <: caps.Pure, +C] extends Any with collection.SeqOps[A, CC, C] with caps.Pure
3535

3636
/**
3737
* $factoryInfo
@@ -120,9 +120,10 @@ object IndexedSeq extends SeqFactory.Delegate[IndexedSeq](Vector) {
120120
}
121121

122122
/** Base trait for immutable indexed Seq operations */
123-
transparent trait IndexedSeqOps[+A, +CC[B] <: collection.StrictSeqOps[B, collection.Seq, collection.Seq[B]], +C]
123+
transparent trait IndexedSeqOps[+A, +CC[B] <: caps.Pure, +C]
124124
extends SeqOps[A, CC, C]
125-
with collection.StrictIndexedSeqOps[A, CC, C] {
125+
with collection.IndexedSeqOps[A, CC, C]
126+
with caps.Pure {
126127

127128
override def slice(from: Int, until: Int): C = {
128129
// since we are immutable we can just share the same collection

library/src/scala/collection/immutable/StrictOptimizedSeqOps.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ import scala.collection.generic.CommonErrors
2121

2222
/** Trait that overrides operations to take advantage of strict builders.
2323
*/
24-
transparent trait StrictOptimizedSeqOps[+A, +CC[B] <: collection.StrictSeqOps[B, collection.Seq, collection.Seq[B]], +C]
24+
transparent trait StrictOptimizedSeqOps[+A, +CC[B] <: collection.SeqOps[B, collection.Seq, collection.Seq[B]] & caps.Pure, +C]
2525
extends Any
26-
with StrictSeqOps[A, CC, C]
26+
with SeqOps[A, CC, C]
2727
with collection.StrictOptimizedSeqOps[A, CC, C]
28-
with StrictOptimizedIterableOps[A, CC, C] {
28+
with StrictOptimizedIterableOps[A, CC, C]
29+
with caps.Pure {
2930

3031
override def distinctBy[B](f: A -> B): C = {
3132
if (lengthCompare(1) <= 0) coll

library/src/scala/collection/immutable/WrappedString.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ import scala.collection.mutable.{Builder, StringBuilder}
3636
*/
3737
@SerialVersionUID(3L)
3838
final class WrappedString(private val self: String) extends AbstractSeq[Char] with IndexedSeq[Char]
39-
with StrictIndexedSeqOps[Char, IndexedSeq, WrappedString]
40-
with Serializable {
39+
with IndexedSeqOps[Char, IndexedSeq, WrappedString]
40+
with Serializable
41+
with caps.Pure {
4142

4243
def apply(i: Int): Char = self.charAt(i)
4344

library/src/scala/collection/mutable/IndexedSeq.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ trait IndexedSeq[T] extends Seq[T]
2828
object IndexedSeq extends SeqFactory.Delegate[IndexedSeq](ArrayBuffer)
2929

3030
transparent trait IndexedSeqOps[A, +CC[_] <: caps.Pure, +C <: AnyRef]
31-
extends scala.collection.StrictIndexedSeqOps[A, CC, C]
32-
with SeqOps[A, CC, C] {
31+
extends scala.collection.IndexedSeqOps[A, CC, C]
32+
with SeqOps[A, CC, C]
33+
with caps.Pure {
3334

3435
/** Modifies this $coll by applying a function to all elements of this $coll.
3536
*

0 commit comments

Comments
 (0)