@@ -17,7 +17,7 @@ import scala.annotation.nowarn
17
17
import scala .collection .generic .DefaultSerializable
18
18
import scala .collection .mutable .StringBuilder
19
19
import scala .util .hashing .MurmurHash3
20
- // import language.experimental.captureChecking
20
+ import language .experimental .captureChecking
21
21
22
22
/** Base Map type */
23
23
trait Map [K , + V ]
@@ -132,7 +132,7 @@ trait MapOps[K, +V, +CC[_, _] <: IterableOps[_, AnyConstr, _], +C]
132
132
/** Similar to `fromIterable`, but returns a Map collection type.
133
133
* Note that the return type is now `CC[K2, V2]`.
134
134
*/
135
- @ `inline` protected final def mapFromIterable [K2 , V2 ](it : Iterable [(K2 , V2 )]): CC [K2 , V2 ] = mapFactory.from(it)
135
+ @ `inline` protected final def mapFromIterable [K2 , V2 ](it : Iterable [(K2 , V2 )]^ ): CC [K2 , V2 ] = mapFactory.from(it)
136
136
137
137
/** The companion object of this map, providing various factory methods.
138
138
*
@@ -319,7 +319,7 @@ trait MapOps[K, +V, +CC[_, _] <: IterableOps[_, AnyConstr, _], +C]
319
319
* @return a new $coll resulting from applying the given collection-valued function
320
320
* `f` to each element of this $coll and concatenating the results.
321
321
*/
322
- def flatMap [K2 , V2 ](f : ((K , V )) => IterableOnce [(K2 , V2 )]): CC [K2 , V2 ] = mapFactory.from(new View .FlatMap (this , f))
322
+ def flatMap [K2 , V2 ](f : ((K , V )) => IterableOnce [(K2 , V2 )]^ ): CC [K2 , V2 ] = mapFactory.from(new View .FlatMap (this , f))
323
323
324
324
/** Returns a new $coll containing the elements from the left hand operand followed by the elements from the
325
325
* right hand operand. The element type of the $coll is the most specific superclass encompassing
@@ -329,15 +329,15 @@ trait MapOps[K, +V, +CC[_, _] <: IterableOps[_, AnyConstr, _], +C]
329
329
* @return a new $coll which contains all elements
330
330
* of this $coll followed by all elements of `suffix`.
331
331
*/
332
- def concat [V2 >: V ](suffix : collection.IterableOnce [(K , V2 )]): CC [K , V2 ] = mapFactory.from(suffix match {
332
+ def concat [V2 >: V ](suffix : collection.IterableOnce [(K , V2 )]^ ): CC [K , V2 ] = mapFactory.from(suffix match {
333
333
case it : Iterable [(K , V2 )] => new View .Concat (this , it)
334
334
case _ => iterator.concat(suffix.iterator)
335
335
})
336
336
337
337
// Not final because subclasses refine the result type, e.g. in SortedMap, the result type is
338
338
// SortedMap's CC, while Map's CC is fixed to Map
339
339
/** Alias for `concat` */
340
- /* @`inline` final*/ def ++ [V2 >: V ](xs : collection.IterableOnce [(K , V2 )]): CC [K , V2 ] = concat(xs)
340
+ /* @`inline` final*/ def ++ [V2 >: V ](xs : collection.IterableOnce [(K , V2 )]^ ): CC [K , V2 ] = concat(xs)
341
341
342
342
override def addString (sb : StringBuilder , start : String , sep : String , end : String ): sb.type =
343
343
iterator.map { case (k, v) => s " $k -> $v" }.addString(sb, start, sep, end)
@@ -351,14 +351,14 @@ trait MapOps[K, +V, +CC[_, _] <: IterableOps[_, AnyConstr, _], +C]
351
351
mapFactory.from(new View .Concat (new View .Appended (new View .Appended (this , elem1), elem2), elems))
352
352
353
353
@ deprecated(" Consider requiring an immutable Map." , " 2.13.0" )
354
- @ `inline` def -- (keys : IterableOnce [K ]): C = {
354
+ @ `inline` def -- (keys : IterableOnce [K ]^ ): C = {
355
355
lazy val keysSet = keys.iterator.to(immutable.Set )
356
356
fromSpecific(this .view.filterKeys(k => ! keysSet.contains(k)))
357
357
}
358
358
359
359
@ deprecated(" Use ++ instead of ++: for collections of type Iterable" , " 2.13.0" )
360
- def ++: [V1 >: V ](that : IterableOnce [(K ,V1 )]): CC [K ,V1 ] = {
361
- val thatIterable : Iterable [(K , V1 )] = that match {
360
+ def ++: [V1 >: V ](that : IterableOnce [(K ,V1 )]^ ): CC [K ,V1 ] = {
361
+ val thatIterable : Iterable [(K , V1 )]^ {that} = that match {
362
362
case that : Iterable [(K , V1 )] => that
363
363
case that => View .from(that)
364
364
}
@@ -381,10 +381,10 @@ object MapOps {
381
381
def map [K2 , V2 ](f : ((K , V )) => (K2 , V2 )): CC [K2 , V2 ] =
382
382
self.mapFactory.from(new View .Map (filtered, f))
383
383
384
- def flatMap [K2 , V2 ](f : ((K , V )) => IterableOnce [(K2 , V2 )]): CC [K2 , V2 ] =
384
+ def flatMap [K2 , V2 ](f : ((K , V )) => IterableOnce [(K2 , V2 )]^ ): CC [K2 , V2 ] =
385
385
self.mapFactory.from(new View .FlatMap (filtered, f))
386
386
387
- override def withFilter (q : ((K , V )) => Boolean ): WithFilter [K , V , IterableCC , CC ] =
387
+ override def withFilter (q : ((K , V )) => Boolean ): WithFilter [K , V , IterableCC , CC ]^ {p, q} =
388
388
new WithFilter [K , V , IterableCC , CC ](self, (kv : (K , V )) => p(kv) && q(kv))
389
389
390
390
}
0 commit comments