Skip to content

Commit d67f99c

Browse files
committed
Drop strict overrides from StrictMapOps and StrictSeqOps
The compiler can properly figure out the return types based on the Pure upper bound on CC
1 parent 882a9c9 commit d67f99c

File tree

2 files changed

+2
-55
lines changed

2 files changed

+2
-55
lines changed

library/src/scala/collection/Map.scala

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -93,40 +93,6 @@ trait Map[K, +V]
9393
/** Map operations for strict maps. */
9494
transparent trait StrictMapOps[K, +V, +CC[_, _] <: IterableOps[_, AnyConstr, _] with caps.Pure, +C]
9595
extends MapOps[K, V, CC, C] with caps.Pure {
96-
97-
override def mapFactory: StrictMapFactory[CC]
98-
override protected def fromSpecific(coll: IterableOnce[(K, V) @uncheckedVariance]^): C
99-
100-
@`inline` override protected def mapFromIterable[K2, V2](it: Iterable[(K2, V2)]^): CC[K2, V2] = mapFactory.from(it)
101-
102-
override def map[K2, V2](f: ((K, V)) => (K2, V2)): CC[K2, V2] = mapFactory.from(new View.Map(this, f))
103-
104-
override def collect[K2, V2](pf: PartialFunction[(K, V), (K2, V2)]^): CC[K2, V2] =
105-
mapFactory.from(new View.Collect(this, pf))
106-
107-
override def flatMap[K2, V2](f: ((K, V)) => IterableOnce[(K2, V2)]^): CC[K2, V2] = mapFactory.from(new View.FlatMap(this, f))
108-
109-
override def concat[V2 >: V](suffix: collection.IterableOnce[(K, V2)]^): CC[K, V2] = mapFactory.from(suffix match {
110-
case it: Iterable[(K, V2)] => new View.Concat(this, it)
111-
case _ => iterator.concat(suffix.iterator)
112-
})
113-
114-
override def ++ [V2 >: V](xs: collection.IterableOnce[(K, V2)]^): CC[K, V2] = concat(xs)
115-
116-
@`inline` override def -- (keys: IterableOnce[K]^): C = {
117-
lazy val keysSet = keys.iterator.to(immutable.Set)
118-
fromSpecific(this.view.filterKeys(k => !keysSet.contains(k)))
119-
}
120-
121-
@deprecated("Use ++ instead of ++: for collections of type Iterable", "2.13.0")
122-
override def ++: [V1 >: V](that: IterableOnce[(K,V1)]^): CC[K,V1] = {
123-
val thatIterable: Iterable[(K, V1)]^{that} = that match {
124-
case that: Iterable[(K, V1)] => that
125-
case that => View.from(that)
126-
}
127-
mapFactory.from(new View.Concat(thatIterable, this))
128-
}
129-
13096
// The original keySet implementation, with a lazy iterator over the keys,
13197
// is only correct if we have a strict Map.
13298
// We restore it here.

library/src/scala/collection/Seq.scala

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -63,25 +63,6 @@ object Seq extends SeqFactory.Delegate[Seq](immutable.Seq)
6363
* Contains strict overrides of SeqOps operations, where the parameters are also captured.
6464
*/
6565
transparent trait StrictSeqOps[+A, +CC[B] <: caps.Pure, +C] extends Any with SeqOps[A, CC, C] with caps.Pure {
66-
override def iterableFactory: StrictIterableFactory[CC]
67-
68-
override def prependedAll[B >: A](prefix: IterableOnce[B]^): CC[B] = iterableFactory.from(prefix match {
69-
case prefix: Iterable[B] => new View.Concat(prefix, this)
70-
case _ => prefix.iterator ++ iterator
71-
})
72-
73-
@inline override final def ++: [B >: A](prefix: IterableOnce[B]^): CC[B] = prependedAll(prefix)
74-
75-
override def appendedAll[B >: A](suffix: IterableOnce[B]^): CC[B] = super.concat(suffix)
76-
77-
@inline override final def :++ [B >: A](suffix: IterableOnce[B]^): CC[B] = appendedAll(suffix)
78-
79-
@inline override final def concat[B >: A](suffix: IterableOnce[B]^): CC[B] = appendedAll(suffix)
80-
81-
override def reverseMap[B](f: A => B): CC[B] = iterableFactory.from(new View.Map(View.fromIteratorProvider(() => reverseIterator), f))
82-
83-
override def patch[B >: A](from: Int, other: IterableOnce[B]^, replaced: Int): CC[B] =
84-
iterableFactory.from(new View.Patched(this, from, other, replaced))
8566
}
8667

8768
/** Base trait for Seq operations
@@ -1042,11 +1023,11 @@ transparent trait SeqOps[+A, +CC[_], +C] extends Any
10421023
* @return a `Found` value containing the index corresponding to the element in the
10431024
* sequence, or the `InsertionPoint` where the element would be inserted if
10441025
* the element is not in the sequence.
1045-
*
1026+
*
10461027
* @note if `to <= from`, the search space is empty, and an `InsertionPoint` at `from`
10471028
* is returned
10481029
*/
1049-
def search[B >: A](elem: B, from: Int, to: Int) (implicit ord: Ordering[B]): SearchResult =
1030+
def search[B >: A](elem: B, from: Int, to: Int) (implicit ord: Ordering[B]): SearchResult =
10501031
linearSearch(view.slice(from, to), elem, math.max(0, from))(ord)
10511032

10521033
private[this] def linearSearch[B >: A](c: View[A]^, elem: B, offset: Int)

0 commit comments

Comments
 (0)