Skip to content

Commit f638614

Browse files
committed
Use {this} and {self} as capture sets instead of untrackedCaptures
1 parent 6689785 commit f638614

File tree

4 files changed

+4
-15
lines changed

4 files changed

+4
-15
lines changed

library/src/scala/collection/Iterator.scala

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import scala.collection.mutable.{ArrayBuffer, ArrayBuilder, Builder, ImmutableBu
1818
import scala.annotation.tailrec
1919
import scala.annotation.unchecked.uncheckedVariance
2020
import scala.runtime.Statics
21-
import caps.unsafe.untrackedCaptures
2221

2322
/** Iterators are data structures that allow to iterate over a sequence
2423
* of elements. They have a `hasNext` method for checking
@@ -918,12 +917,7 @@ trait Iterator[+A] extends IterableOnce[A] with IterableOnceOps[A, Iterator, Ite
918917
*/
919918
def patch[B >: A](from: Int, patchElems: Iterator[B]^, replaced: Int): Iterator[B]^{this, patchElems} =
920919
new AbstractIterator[B] {
921-
// TODO We should be able to prove that origElems is safe even though it is
922-
// declared as Iterator[B]^. We could show that origElems is never assigned a
923-
// freh cap. Maybe we can invent another annotation that is checked and that
924-
// shows that the `^` is just used as an upper bound for concete non-fresh
925-
// capabilities.
926-
@untrackedCaptures private[this] var origElems: Iterator[B]^ = self
920+
private[this] var origElems: Iterator[B]^{self} = self
927921
// > 0 => that many more elems from `origElems` before switching to `patchElems`
928922
// 0 => need to drop elems from `origElems` and start using `patchElems`
929923
// -1 => have dropped elems from `origElems`, will be using `patchElems` until it's empty

library/src/scala/collection/generic/IsIterable.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ package generic
1515

1616
import scala.language.`2.13`
1717
import language.experimental.captureChecking
18-
import caps.unsafe.untrackedCaptures
1918

2019
/** A trait which can be used to avoid code duplication when defining extension
2120
* methods that should be applicable both to existing Scala collections (i.e.,
@@ -124,8 +123,7 @@ transparent trait IsIterable[Repr] extends IsIterableOnce[Repr] {
124123
type C
125124

126125
@deprecated("'conversion' is now a method named 'apply'", "2.13.0")
127-
@untrackedCaptures
128-
override val conversion: Repr => IterableOps[A, Iterable, C] = apply(_)
126+
override val conversion: Repr ->{this} IterableOps[A, Iterable, C] = apply(_)
129127

130128
/** A conversion from the type `Repr` to `IterableOps[A, Iterable, C]` */
131129
def apply(coll: Repr): IterableOps[A, Iterable, C]

library/src/scala/collection/generic/IsSeq.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ package generic
1515

1616
import scala.language.`2.13`
1717
import language.experimental.captureChecking
18-
import caps.unsafe.untrackedCaptures
1918

2019
import scala.reflect.ClassTag
2120

@@ -32,8 +31,7 @@ import scala.reflect.ClassTag
3231
transparent trait IsSeq[Repr] extends IsIterable[Repr] {
3332

3433
@deprecated("'conversion' is now a method named 'apply'", "2.13.0")
35-
@untrackedCaptures
36-
override val conversion: Repr => SeqOps[A, Iterable, C] = apply(_)
34+
override val conversion: Repr ->{this} SeqOps[A, Iterable, C] = apply(_)
3735

3836
/** A conversion from the type `Repr` to `SeqOps[A, Iterable, C]`
3937
*

library/src/scala/collection/immutable/LazyListIterable.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import scala.collection.generic.SerializeEnd
2525
import scala.collection.mutable.{Builder, ReusableBuilder, StringBuilder}
2626
import scala.language.implicitConversions
2727
import scala.runtime.Statics
28-
import caps.unsafe.untrackedCaptures
2928

3029
/** This class implements an immutable linked list. We call it "lazy"
3130
* because it computes its elements only when they are needed.
@@ -1375,7 +1374,7 @@ object LazyListIterable extends IterableFactory[LazyListIterable] {
13751374

13761375
private final class WithFilter[A] private[LazyListIterable](lazyList: LazyListIterable[A]^, p: A => Boolean)
13771376
extends collection.WithFilter[A, LazyListIterable] {
1378-
@untrackedCaptures private[this] val filtered = lazyList.filter(p)
1377+
private[this] val filtered: LazyListIterable[A]^{this} = lazyList.filter(p)
13791378
def map[B](f: A => B): LazyListIterable[B]^{this, f} = filtered.map(f)
13801379
def flatMap[B](f: A => IterableOnce[B]^): LazyListIterable[B]^{this, f} = filtered.flatMap(f)
13811380
def foreach[U](f: A => U): Unit = filtered.foreach(f)

0 commit comments

Comments
 (0)