Skip to content

Commit 8eb1a8e

Browse files
committed
Drop StrictMapOps and replace them with caps.Pure bounds
1 parent 0cf4715 commit 8eb1a8e

File tree

6 files changed

+15
-19
lines changed

6 files changed

+15
-19
lines changed

library/src/scala/collection/Iterable.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,7 @@ trait MapFactoryDefaults[K, +V,
10451045
trait SortedMapFactoryDefaults[K, +V,
10461046
+CC[x, y] <: Map[x, y] with SortedMapOps[x, y, CC, CC[x, y]] with UnsortedCC[x, y],
10471047
+WithFilterCC[x] <: IterableOps[x, WithFilterCC, WithFilterCC[x]] with Iterable[x],
1048-
+UnsortedCC[x, y] <: Map[x, y]] extends SortedMapOps[K, V, CC, CC[K, V @uncheckedVariance]] with StrictMapOps[K, V, UnsortedCC, CC[K, V @uncheckedVariance]] {
1048+
+UnsortedCC[x, y] <: Map[x, y]] extends SortedMapOps[K, V, CC, CC[K, V @uncheckedVariance]] with MapOps[K, V, UnsortedCC, CC[K, V @uncheckedVariance]] with caps.Pure {
10491049
self: IterableOps[(K, V), WithFilterCC, _] =>
10501050

10511051
override def empty: CC[K, V @uncheckedVariance] = sortedMapFactory.empty(using ordering)

library/src/scala/collection/Map.scala

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import scala.util.hashing.MurmurHash3
2424
/** Base Map type */
2525
trait Map[K, +V]
2626
extends Iterable[(K, V)]
27-
with StrictMapOps[K, V, Map, Map[K, V]]
27+
with MapOps[K, V, Map, Map[K, V]]
2828
with MapFactoryDefaults[K, V, Map, Iterable]
2929
with Equals
3030
with caps.Pure {
@@ -89,14 +89,6 @@ trait Map[K, +V]
8989
override def toString(): String = super[Iterable].toString() // Because `Function1` overrides `toString` too
9090
}
9191

92-
/** Map operations for strict maps. */
93-
transparent trait StrictMapOps[K, +V, +CC[_, _] <: IterableOps[_, AnyConstr, _] with caps.Pure, +C]
94-
extends MapOps[K, V, CC, C] with caps.Pure {
95-
// The original keySet implementation, with a lazy iterator over the keys,
96-
// is only correct if we have a strict Map.
97-
// We restore it here.
98-
}
99-
10092
/** Base Map implementation type
10193
*
10294
* @tparam K Type of keys
@@ -220,12 +212,12 @@ transparent trait MapOps[K, +V, +CC[_, _] <: IterableOps[_, AnyConstr, _], +C]
220212

221213
/** A generic trait that is reused by keyset implementations.
222214
* Note that this version of KeySet copies all the keys into an interval val.
223-
* See [[StrictMapOps.LazyKeySet]] for a version that lazily captures the map.
215+
* See [[MapOps.LazyKeySet]] for a version that lazily captures the map.
224216
*/
225217
protected trait GenKeySet { this: Set[K] =>
226218
// CC note: this is unavoidable to make the KeySet pure.
227219
private[MapOps] val allKeys = MapOps.this.keysIterator.toSet
228-
// We restore the lazy behavior in StrictMapOps
220+
// We restore the lazy behavior in LazyKeySet
229221
def iterator: Iterator[K] =
230222
allKeys.iterator
231223
def contains(key: K): Boolean = allKeys.contains(key)

library/src/scala/collection/SeqMap.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ import scala.annotation.nowarn
3131
*/
3232

3333
trait SeqMap[K, +V] extends Map[K, V]
34-
with StrictMapOps[K, V, SeqMap, SeqMap[K, V]]
35-
with MapFactoryDefaults[K, V, SeqMap, Iterable] {
34+
with MapOps[K, V, SeqMap, SeqMap[K, V]]
35+
with MapFactoryDefaults[K, V, SeqMap, Iterable]
36+
with caps.Pure {
3637
@nowarn("""cat=deprecation&origin=scala\.collection\.Iterable\.stringPrefix""")
3738
override protected[this] def stringPrefix: String = "SeqMap"
3839

library/src/scala/collection/SortedMap.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ trait SortedMap[K, +V]
5151
}
5252

5353
transparent trait SortedMapOps[K, +V, +CC[X, Y] <: Map[X, Y] with SortedMapOps[X, Y, CC, _] with caps.Pure, +C <: SortedMapOps[K, V, CC, C]]
54-
extends StrictMapOps[K, V, Map, C]
55-
with SortedOps[K, C] {
54+
extends MapOps[K, V, Map, C]
55+
with SortedOps[K, C]
56+
with caps.Pure {
5657

5758
/** The companion object of this sorted map, providing various factory methods.
5859
*

library/src/scala/collection/immutable/Map.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ trait Map[K, +V]
6464
*/
6565
transparent trait MapOps[K, +V, +CC[X, +Y] <: MapOps[X, Y, CC, _], +C <: MapOps[K, V, CC, C]]
6666
extends IterableOps[(K, V), Iterable, C]
67-
with collection.StrictMapOps[K, V, CC, C] {
67+
with collection.MapOps[K, V, CC, C]
68+
with caps.Pure {
6869

6970
protected def coll: C with CC[K, V]
7071

library/src/scala/collection/mutable/Map.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,12 @@ trait Map[K, V]
6868
*/
6969
transparent trait MapOps[K, V, +CC[X, Y] <: MapOps[X, Y, CC, _], +C <: MapOps[K, V, CC, C]]
7070
extends IterableOps[(K, V), Iterable, C]
71-
with collection.StrictMapOps[K, V, CC, C]
71+
with collection.MapOps[K, V, CC, C]
7272
with Cloneable[C]
7373
with Builder[(K, V), C]
7474
with Growable[(K, V)]
75-
with Shrinkable[K] {
75+
with Shrinkable[K]
76+
with caps.Pure {
7677

7778
def result(): C = coll
7879

0 commit comments

Comments
 (0)