@@ -14,10 +14,9 @@ package scala.collection
1414
1515import scala .collection .mutable .{ArrayBuffer , ArrayBuilder , Builder , ImmutableBuilder }
1616import scala .annotation .tailrec
17- import scala .annotation .unchecked .{ uncheckedVariance , uncheckedCaptures }
17+ import scala .annotation .unchecked .uncheckedVariance
1818import scala .runtime .Statics
1919import language .experimental .captureChecking
20- import annotation .unchecked .uncheckedCaptures
2120
2221
2322/** Iterators are data structures that allow to iterate over a sequence
@@ -161,12 +160,12 @@ trait Iterator[+A] extends IterableOnce[A] with IterableOnceOps[A, Iterator, Ite
161160
162161 require(size >= 1 && step >= 1 , f " size= $size%d and step= $step%d, but both must be positive " )
163162
164- private [this ] var buffer : Array [B @ uncheckedCaptures ] = null // current result
165- private [this ] var prev : Array [B @ uncheckedCaptures ] = null // if sliding, overlap from previous result
163+ private [this ] var buffer : Array [B ] = null // current result
164+ private [this ] var prev : Array [B ] = null // if sliding, overlap from previous result
166165 private [this ] var first = true // if !first, advancing may skip ahead
167166 private [this ] var filled = false // whether the buffer is "hot"
168167 private [this ] var partial = true // whether to emit partial sequence
169- private [this ] var padding : () -> B @ uncheckedCaptures = null // what to pad short sequences with
168+ private [this ] var padding : () -> B = null // what to pad short sequences with
170169 private [this ] def pad = padding != null // irrespective of partial flag
171170 private [this ] def newBuilder = {
172171 val b = ArrayBuilder .make[Any ]
@@ -258,7 +257,7 @@ trait Iterator[+A] extends IterableOnce[A] with IterableOnceOps[A, Iterator, Ite
258257 }
259258 // segment must have data, and must be complete unless they allow partial
260259 val ok = index > 0 && (partial || index == size)
261- if (ok) buffer = builder.result().asInstanceOf [Array [B @ uncheckedCaptures ]]
260+ if (ok) buffer = builder.result().asInstanceOf [Array [B ]]
262261 else prev = null
263262 ok
264263 }
@@ -417,8 +416,7 @@ trait Iterator[+A] extends IterableOnce[A] with IterableOnceOps[A, Iterator, Ite
417416
418417 @ deprecated(" Call scanRight on an Iterable instead." , " 2.13.0" )
419418 def scanRight [B ](z : B )(op : (A , B ) => B ): Iterator [B ]^ {this } =
420- ArrayBuffer .from[A @ uncheckedCaptures](this ).scanRight(z)(op).iterator
421- // @uncheckedCaptures is safe since the ArrayBuffer is local temporrary storage
419+ ArrayBuffer .from[A ](this ).scanRight(z)(op).iterator
422420
423421 def indexWhere (p : A => Boolean , from : Int = 0 ): Int = {
424422 var i = math.max(from, 0 )
@@ -561,7 +559,7 @@ trait Iterator[+A] extends IterableOnce[A] with IterableOnceOps[A, Iterator, Ite
561559 */
562560 def distinctBy [B ](f : A -> B ): Iterator [A ]^ {this } = new AbstractIterator [A ] {
563561
564- private [this ] val traversedValues = mutable.HashSet .empty[B @ uncheckedCaptures ]
562+ private [this ] val traversedValues = mutable.HashSet .empty[B ]
565563 private [this ] var nextElementDefined : Boolean = false
566564 private [this ] var nextElement : A = _
567565
@@ -704,7 +702,7 @@ trait Iterator[+A] extends IterableOnce[A] with IterableOnceOps[A, Iterator, Ite
704702 */
705703 private [this ] var status = 0
706704 private def store (a : A ): Unit = {
707- if (lookahead == null ) lookahead = new mutable.Queue [A @ uncheckedCaptures ]
705+ if (lookahead == null ) lookahead = new mutable.Queue [A ]
708706 lookahead += a
709707 }
710708 def hasNext = {
@@ -867,8 +865,8 @@ trait Iterator[+A] extends IterableOnce[A] with IterableOnceOps[A, Iterator, Ite
867865 * @note Reuse: $consumesOneAndProducesTwoIterators
868866 */
869867 def duplicate : (Iterator [A ]^ {this }, Iterator [A ]^ {this }) = {
870- val gap = new scala.collection.mutable.Queue [A @ uncheckedCaptures ]
871- var ahead : Iterator [A @ uncheckedCaptures ] = null // ahead is captured by Partner, so A is not recognized as parametric
868+ val gap = new scala.collection.mutable.Queue [A ]
869+ var ahead : Iterator [A ] = null // ahead is captured by Partner, so A is not recognized as parametric
872870 class Partner extends AbstractIterator [A ] {
873871 override def knownSize : Int = self.synchronized {
874872 val thisSize = self.knownSize
@@ -1145,9 +1143,9 @@ object Iterator extends IterableFactory[Iterator] {
11451143 * Nested ConcatIterators are merged to avoid blowing the stack.
11461144 */
11471145 private final class ConcatIterator [+ A ](val from : Iterator [A ]^ ) extends AbstractIterator [A ] {
1148- private var current : Iterator [A @ uncheckedCaptures ]^ {from* } = from
1149- private var tail : ConcatIteratorCell [A @ uncheckedVariance @ uncheckedCaptures ] = null
1150- private var last : ConcatIteratorCell [A @ uncheckedVariance @ uncheckedCaptures ] = null
1146+ private var current : Iterator [A ]^ {from* } = from
1147+ private var tail : ConcatIteratorCell [A @ uncheckedVariance] = null
1148+ private var last : ConcatIteratorCell [A @ uncheckedVariance] = null
11511149 private var currentHasNextChecked = false
11521150
11531151 def hasNext =
@@ -1216,7 +1214,7 @@ object Iterator extends IterableFactory[Iterator] {
12161214 }
12171215 }
12181216
1219- private [this ] final class ConcatIteratorCell [A ](head : => IterableOnce [A ]^ , var tail : ConcatIteratorCell [A @ uncheckedCaptures ]) {
1217+ private [this ] final class ConcatIteratorCell [A ](head : => IterableOnce [A ]^ , var tail : ConcatIteratorCell [A ]) {
12201218 def headIterator : Iterator [A ]^ {this } = head.iterator // CC todo: can't use {head} as capture set, gives "cannot establish a reference"
12211219 }
12221220
@@ -1277,8 +1275,8 @@ object Iterator extends IterableFactory[Iterator] {
12771275 * type `A` and update an internal state of type `S`.
12781276 */
12791277 private final class UnfoldIterator [A , S ](init : S )(f : S => Option [(A , S )])extends AbstractIterator [A ] {
1280- private [this ] var state : S @ uncheckedCaptures = init
1281- private [this ] var nextResult : Option [(A , S )] @ uncheckedCaptures = null
1278+ private [this ] var state : S = init
1279+ private [this ] var nextResult : Option [(A , S )] = null
12821280
12831281 override def hasNext : Boolean = {
12841282 if (nextResult eq null ) {
0 commit comments