Skip to content

Commit e304d8a

Browse files
committed
Move more methods from SeqOps to SeqViewOps
1 parent 9ef2676 commit e304d8a

File tree

2 files changed

+35
-9
lines changed

2 files changed

+35
-9
lines changed

scala2-library-cc/src/scala/collection/Seq.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ trait SeqOps[+A, +CC[_], +C] extends Any with SeqViewOps[A, CC, C] { self =>
206206
*
207207
* @return a new $coll consisting of all the elements of this $coll without duplicates.
208208
*/
209-
def distinct: C = distinctBy(identity)
209+
override def distinct: C = distinctBy(identity)
210210

211211
/** Selects all the elements of this $coll ignoring the duplicates as determined by `==` after applying
212212
* the transforming function `f`.
@@ -215,7 +215,7 @@ trait SeqOps[+A, +CC[_], +C] extends Any with SeqViewOps[A, CC, C] { self =>
215215
* @tparam B the type of the elements after being transformed by `f`
216216
* @return a new $coll consisting of all the elements of this $coll without duplicates.
217217
*/
218-
def distinctBy[B](f: A -> B): C = fromSpecific(new View.DistinctBy(this, f))
218+
override def distinctBy[B](f: A -> B): C = fromSpecific(new View.DistinctBy(this, f))
219219

220220
/** Returns new $coll with elements in reversed order.
221221
*
@@ -293,7 +293,7 @@ trait SeqOps[+A, +CC[_], +C] extends Any with SeqViewOps[A, CC, C] { self =>
293293
* all elements of this $coll followed by the minimal number of occurrences of `elem` so
294294
* that the resulting collection has a length of at least `len`.
295295
*/
296-
def padTo[B >: A](len: Int, elem: B): CC[B] = iterableFactory.from(new View.PadTo(this, len, elem))
296+
override def padTo[B >: A](len: Int, elem: B): CC[B] = iterableFactory.from(new View.PadTo(this, len, elem))
297297

298298
/** Computes the length of the longest segment that starts from the first element
299299
* and whose elements all satisfy some predicate.
@@ -544,7 +544,7 @@ trait SeqOps[+A, +CC[_], +C] extends Any with SeqViewOps[A, CC, C] { self =>
544544
* // List(b, b, a)
545545
* }}}
546546
*/
547-
def permutations: Iterator[C] =
547+
override def permutations: Iterator[C] =
548548
if (isEmpty) Iterator.single(coll)
549549
else new PermutationsItr
550550

@@ -585,7 +585,7 @@ trait SeqOps[+A, +CC[_], +C] extends Any with SeqViewOps[A, CC, C] { self =>
585585
* // List(b, a)
586586
* }}}
587587
*/
588-
def combinations(n: Int): Iterator[C] =
588+
override def combinations(n: Int): Iterator[C] =
589589
if (n < 0 || n > size) Iterator.empty
590590
else new CombinationsItr(n)
591591

@@ -759,7 +759,7 @@ trait SeqOps[+A, +CC[_], +C] extends Any with SeqViewOps[A, CC, C] { self =>
759759
* List("Bobby", "Bob", "John", "Steve", "Tom")
760760
* }}}
761761
*/
762-
def sortWith(lt: (A, A) => Boolean): C = sorted(Ordering.fromLessThan(lt))
762+
override def sortWith(lt: (A, A) => Boolean): C = sorted(Ordering.fromLessThan(lt))
763763

764764
/** Sorts this $coll according to the Ordering which results from transforming
765765
* an implicitly given Ordering with a transformation function.
@@ -786,7 +786,7 @@ trait SeqOps[+A, +CC[_], +C] extends Any with SeqViewOps[A, CC, C] { self =>
786786
* res0: Array[String] = Array(The, dog, fox, the, lazy, over, brown, quick, jumped)
787787
* }}}
788788
*/
789-
def sortBy[B](f: A => B)(implicit ord: Ordering[B]): C = sorted(ord on f)
789+
override def sortBy[B](f: A => B)(implicit ord: Ordering[B]): C = sorted(ord on f)
790790

791791
/** Produces the range of all indices of this sequence.
792792
* $willForceEvaluation
@@ -944,7 +944,7 @@ trait SeqOps[+A, +CC[_], +C] extends Any with SeqViewOps[A, CC, C] { self =>
944944
* except that `replaced` elements starting from `from` are replaced
945945
* by all the elements of `other`.
946946
*/
947-
def patch[B >: A](from: Int, other: IterableOnce[B]^, replaced: Int): CC[B] =
947+
override def patch[B >: A](from: Int, other: IterableOnce[B]^, replaced: Int): CC[B] =
948948
iterableFactory.from(new View.Patched(this, from, other, replaced))
949949
.unsafeAssumePure // assume pure OK since iterableFactory.from is eager for Seq
950950

scala2-library-cc/src/scala/collection/SeqView.scala

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,38 @@ trait SeqViewOps[+A, +CC[_], +C] extends Any with IterableOps[A, CC, C] {
3434
def reverse: C^{this}
3535
def sorted[B >: A](implicit ord: Ordering[B]): C^{this}
3636

37-
// Placeholder implementation for that method in SeqOps.
37+
// Placeholder implementations for the corresponding methods in SeqOps.
3838
// This is needed due to the change in the class hierarchy in cc stdlib.
3939
// See #19660 and #19819.
40+
// -------------------
4041
def updated[B >: A](index: Int, elem: B): CC[B]^{this} =
4142
assert(false, "This is a placeholder implementation in the capture checked Scala 2 library.")
4243
???
44+
def padTo[B >: A](len: Int, elem: B): CC[B]^{this} =
45+
assert(false, "This is a placeholder implementation in the capture checked Scala 2 library.")
46+
???
47+
def patch[B >: A](from: Int, other: IterableOnce[B]^, replaced: Int): CC[B]^{this, other} =
48+
assert(false, "This is a placeholder implementation in the capture checked Scala 2 library.")
49+
???
50+
def combinations(n: Int): Iterator[C^{this}]^{this} =
51+
assert(false, "This is a placeholder implementation in the capture checked Scala 2 library.")
52+
???
53+
def sortBy[B](f: A => B)(implicit ord: Ordering[B]): C^{this, f} =
54+
assert(false, "This is a placeholder implementation in the capture checked Scala 2 library.")
55+
???
56+
def sortWith(lt: (A, A) => Boolean): C^{this, lt} =
57+
assert(false, "This is a placeholder implementation in the capture checked Scala 2 library.")
58+
???
59+
def permutations: Iterator[C^{this}]^{this} =
60+
assert(false, "This is a placeholder implementation in the capture checked Scala 2 library.")
61+
???
62+
def distinct: C^{this} =
63+
assert(false, "This is a placeholder implementation in the capture checked Scala 2 library.")
64+
???
65+
def distinctBy[B](f: A -> B): C^{this} =
66+
assert(false, "This is a placeholder implementation in the capture checked Scala 2 library.")
67+
???
68+
// -------------------
4369

4470
def reverseIterator: Iterator[A]^{this} = reversed.iterator
4571
}

0 commit comments

Comments
 (0)