Skip to content

Commit 1530829

Browse files
committed
Capture check stdlib under new scheme
1 parent f61fe69 commit 1530829

File tree

12 files changed

+20
-21
lines changed

12 files changed

+20
-21
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] with Iterable
682682

683683
def map[B](f: A => B): CC[B]^{this, f} = iterableFactory.from(new View.Map(this, f))
684684

685-
def flatMap[B](f: A => IterableOnce[B]^): CC[B]^{this, f} = iterableFactory.from(new View.FlatMap(this, f))
685+
def flatMap[B](@caps.use f: A => IterableOnce[B]^): CC[B]^{this, f*} = iterableFactory.from(new View.FlatMap(this, f))
686686

687687
def flatten[B](implicit asIterable: A -> IterableOnce[B]): CC[B]^{this} = flatMap(asIterable)
688688

@@ -902,7 +902,7 @@ object IterableOps {
902902
def map[B](f: A => B): CC[B]^{this, f} =
903903
self.iterableFactory.from(new View.Map(filtered, f))
904904

905-
def flatMap[B](f: A => IterableOnce[B]^): CC[B]^{this, f} =
905+
def flatMap[B](@caps.use f: A => IterableOnce[B]^): CC[B]^{this, f*} =
906906
self.iterableFactory.from(new View.FlatMap(filtered, f))
907907

908908
def foreach[U](f: A => U): Unit = filtered.foreach(f)

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,9 @@ final class IterableOnceExtensionMethods[A](private val it: IterableOnce[A]) ext
246246
}
247247

248248
@deprecated("Use .iterator.flatMap instead or consider requiring an Iterable", "2.13.0")
249-
def flatMap[B](f: A => IterableOnce[B]^): IterableOnce[B]^{f} = it match {
249+
def flatMap[B](@caps.use f: A => IterableOnce[B]^): IterableOnce[B]^{f*} = it match
250250
case it: Iterable[A] => it.flatMap(f)
251251
case _ => it.iterator.flatMap(f)
252-
}
253252

254253
@deprecated("Use .iterator.sameElements instead", "2.13.0")
255254
def sameElements[B >: A](that: IterableOnce[B]): Boolean = it.iterator.sameElements(that)
@@ -439,7 +438,7 @@ trait IterableOnceOps[+A, +CC[_], +C] extends Any { this: IterableOnce[A]^ =>
439438
* @return a new $coll resulting from applying the given collection-valued function
440439
* `f` to each element of this $coll and concatenating the results.
441440
*/
442-
def flatMap[B](f: A => IterableOnce[B]^): CC[B]^{this, f}
441+
def flatMap[B](@caps.use f: A => IterableOnce[B]^): CC[B]^{this, f*}
443442

444443
/** Converts this $coll of iterable collections into
445444
* a $coll formed by the elements of these iterable

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ trait Iterator[+A] extends IterableOnce[A] with IterableOnceOps[A, Iterator, Ite
588588
def next() = f(self.next())
589589
}
590590

591-
def flatMap[B](f: A => IterableOnce[B]^): Iterator[B]^{this, f} = new AbstractIterator[B] {
591+
def flatMap[B](@caps.use f: A => IterableOnce[B]^): Iterator[B]^{this, f*} = new AbstractIterator[B] {
592592
private[this] var cur: Iterator[B]^{f} = Iterator.empty
593593
/** Trillium logic boolean: -1 = unknown, 0 = false, 1 = true */
594594
private[this] var _hasNext: Int = -1
@@ -623,7 +623,7 @@ trait Iterator[+A] extends IterableOnce[A] with IterableOnceOps[A, Iterator, Ite
623623
}
624624
}
625625

626-
def flatten[B](implicit ev: A -> IterableOnce[B]): Iterator[B]^{this} =
626+
def flatten[B](implicit ev: A -> IterableOnce[B]): Iterator[B]^{this, ev*} =
627627
flatMap[B](ev)
628628

629629
def concat[B >: A](xs: => IterableOnce[B]^): Iterator[B]^{this, xs} = new Iterator.ConcatIterator[B](self).concat(xs)
@@ -982,7 +982,7 @@ object Iterator extends IterableFactory[Iterator] {
982982
/** Creates a target $coll from an existing source collection
983983
*
984984
* @param source Source collection
985-
* @tparam A the type of the collections elements
985+
* @tparam A the type of the collection's elements
986986
* @return a new $coll with the elements of `source`
987987
*/
988988
override def from[A](source: IterableOnce[A]^): Iterator[A]^{source} = source.iterator
@@ -1003,7 +1003,7 @@ object Iterator extends IterableFactory[Iterator] {
10031003

10041004
/**
10051005
* @return A builder for $Coll objects.
1006-
* @tparam A the type of the ${coll}s elements
1006+
* @tparam A the type of the ${coll}'s elements
10071007
*/
10081008
def newBuilder[A]: Builder[A, Iterator[A]] =
10091009
new ImmutableBuilder[A, Iterator[A]](empty[A]) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ trait MapOps[K, +V, +CC[_, _] <: IterableOps[_, AnyConstr, _], +C]
321321
* @return a new $coll resulting from applying the given collection-valued function
322322
* `f` to each element of this $coll and concatenating the results.
323323
*/
324-
def flatMap[K2, V2](f: ((K, V)) => IterableOnce[(K2, V2)]^): CC[K2, V2] = mapFactory.from(new View.FlatMap(this, f))
324+
def flatMap[K2, V2](@caps.use f: ((K, V)) => IterableOnce[(K2, V2)]^): CC[K2, V2] = mapFactory.from(new View.FlatMap(this, f))
325325

326326
/** Returns a new $coll containing the elements from the left hand operand followed by the elements from the
327327
* right hand operand. The element type of the $coll is the most specific superclass encompassing
@@ -383,7 +383,7 @@ object MapOps {
383383
def map[K2, V2](f: ((K, V)) => (K2, V2)): CC[K2, V2]^{this, f} =
384384
self.mapFactory.from(new View.Map(filtered, f))
385385

386-
def flatMap[K2, V2](f: ((K, V)) => IterableOnce[(K2, V2)]^): CC[K2, V2]^{this, f} =
386+
def flatMap[K2, V2](@caps.use f: ((K, V)) => IterableOnce[(K2, V2)]^): CC[K2, V2]^{this, f*} =
387387
self.mapFactory.from(new View.FlatMap(filtered, f))
388388

389389
override def withFilter(q: ((K, V)) => Boolean): WithFilter[K, V, IterableCC, CC]^{this, q} =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ object SortedMapOps {
208208
def map[K2 : Ordering, V2](f: ((K, V)) => (K2, V2)): CC[K2, V2] =
209209
self.sortedMapFactory.from(new View.Map(filtered, f))
210210

211-
def flatMap[K2 : Ordering, V2](f: ((K, V)) => IterableOnce[(K2, V2)]^): CC[K2, V2] =
211+
def flatMap[K2 : Ordering, V2](@caps.use f: ((K, V)) => IterableOnce[(K2, V2)]^): CC[K2, V2] =
212212
self.sortedMapFactory.from(new View.FlatMap(filtered, f))
213213

214214
override def withFilter(q: ((K, V)) => Boolean): WithFilter[K, V, IterableCC, MapCC, CC]^{this, q} =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ trait StrictOptimizedIterableOps[+A, +CC[_], +C]
104104
b.result()
105105
}
106106

107-
override def flatMap[B](f: A => IterableOnce[B]^): CC[B] =
107+
override def flatMap[B](@caps.use f: A => IterableOnce[B]^): CC[B] =
108108
strictOptimizedFlatMap(iterableFactory.newBuilder, f)
109109

110110
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ trait StrictOptimizedMapOps[K, +V, +CC[_, _] <: IterableOps[_, AnyConstr, _], +C
2929
override def map[K2, V2](f: ((K, V)) => (K2, V2)): CC[K2, V2] =
3030
strictOptimizedMap(mapFactory.newBuilder, f)
3131

32-
override def flatMap[K2, V2](f: ((K, V)) => IterableOnce[(K2, V2)]^): CC[K2, V2] =
32+
override def flatMap[K2, V2](@caps.use f: ((K, V)) => IterableOnce[(K2, V2)]^): CC[K2, V2] =
3333
strictOptimizedFlatMap(mapFactory.newBuilder, f)
3434

3535
override def concat[V2 >: V](suffix: IterableOnce[(K, V2)]^): CC[K, V2] =

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,8 @@ object View extends IterableFactory[View] {
309309

310310
/** A view that flatmaps elements of the underlying collection. */
311311
@SerialVersionUID(3L)
312-
class FlatMap[A, B](underlying: SomeIterableOps[A]^, f: A => IterableOnce[B]^) extends AbstractView[B] {
313-
def iterator: Iterator[B]^{underlying, f} = underlying.iterator.flatMap(f)
312+
class FlatMap[A, B](underlying: SomeIterableOps[A]^, @caps.use f: A => IterableOnce[B]^) extends AbstractView[B] {
313+
def iterator: Iterator[B]^{underlying, f*} = underlying.iterator.flatMap(f)
314314
override def knownSize: Int = if (underlying.knownSize == 0) 0 else super.knownSize
315315
override def isEmpty: Boolean = iterator.isEmpty
316316
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ abstract class WithFilter[+A, +CC[_]] extends Serializable {
4545
* of the filtered outer $coll and
4646
* concatenating the results.
4747
*/
48-
def flatMap[B](f: A => IterableOnce[B]^): CC[B]^{this, f}
48+
def flatMap[B](@caps.use f: A => IterableOnce[B]^): CC[B]^{this, f*}
4949

5050
/** Applies a function `f` to all elements of the `filtered` outer $coll.
5151
*

scala2-library-cc/src/scala/collection/immutable/LazyListIterable.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ final class LazyListIterable[+A] private(@untrackedCaptures lazyState: () => Laz
592592
*/
593593
// optimisations are not for speed, but for functionality
594594
// see tickets #153, #498, #2147, and corresponding tests in run/ (as well as run/stream_flatmap_odds.scala)
595-
override def flatMap[B](f: A => IterableOnce[B]^): LazyListIterable[B]^{this, f} =
595+
override def flatMap[B](@caps.use f: A => IterableOnce[B]^): LazyListIterable[B]^{this, f} =
596596
if (knownIsEmpty) LazyListIterable.empty
597597
else LazyListIterable.flatMapImpl(this, f)
598598

@@ -1307,7 +1307,7 @@ object LazyListIterable extends IterableFactory[LazyListIterable] {
13071307
extends collection.WithFilter[A, LazyListIterable] {
13081308
private[this] val filtered = lazyList.filter(p)
13091309
def map[B](f: A => B): LazyListIterable[B]^{this, f} = filtered.map(f)
1310-
def flatMap[B](f: A => IterableOnce[B]^): LazyListIterable[B]^{this, f} = filtered.flatMap(f)
1310+
def flatMap[B](@caps.use f: A => IterableOnce[B]^): LazyListIterable[B]^{this, f} = filtered.flatMap(f)
13111311
def foreach[U](f: A => U): Unit = filtered.foreach(f)
13121312
def withFilter(q: A => Boolean): collection.WithFilter[A, LazyListIterable]^{this, q} = new WithFilter(filtered, q)
13131313
}

scala2-library-cc/src/scala/collection/immutable/List.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ sealed abstract class List[+A]
286286
}
287287
}
288288

289-
final override def flatMap[B](f: A => IterableOnce[B]^): List[B] = {
289+
final override def flatMap[B](@caps.use f: A => IterableOnce[B]^): List[B] = {
290290
var rest = this
291291
var h: ::[B] = null
292292
var t: ::[B] = null

scala2-library-cc/src/scala/collection/immutable/TreeSeqMap.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ final class TreeSeqMap[K, +V] private (
234234
bdr.result()
235235
}
236236

237-
override def flatMap[K2, V2](f: ((K, V)) => IterableOnce[(K2, V2)]^): TreeSeqMap[K2, V2] = {
237+
override def flatMap[K2, V2](@caps.use f: ((K, V)) => IterableOnce[(K2, V2)]^): TreeSeqMap[K2, V2] = {
238238
val bdr = newBuilder[K2, V2](orderedBy)
239239
val iter = ordering.iterator
240240
while (iter.hasNext) {

0 commit comments

Comments
 (0)