Created
January 2, 2026 09:50
-
-
Save xuwei-k/12d5b17ee9b9d96933b7f0f483e3f142 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 17a18,19 | |
| > import language.experimental.captureChecking | |
| > | |
| 25a28 | |
| > import caps.unsafe.untrackedCaptures | |
| 250c253 | |
| < * @see [[https://docs.scala-lang.org/overviews/collections-2.13/concrete-immutable-collection-classes.html#lazylists "Scala's Collection Library overview"]] | |
| --- | |
| > * @see [[https://docs.scala-lang.org/overviews/collections-2.13/concrete-immutable-collection-classes.html#lazylistsIterable "Scala's Collection Library overview"]] | |
| 265,267d267 | |
| < * @note Under Capture Checking, LazyList is unsound with regards to lazy/strict separation of collections. | |
| < * LazyList as-is will not be capture checked and might be deprecated in the future. | |
| < * Use LazyListIterable instead. | |
| 270,273c270,272 | |
| < final class LazyList[+A] private (lazyState: AnyRef /* EmptyMarker.type | () => LazyList[A] */) | |
| < extends AbstractSeq[A] | |
| < with LinearSeq[A] | |
| < with LinearSeqOps[A, LazyList, LazyList[A]] | |
| --- | |
| > final class LazyList[+A] private (lazyState: LazyList.EmptyMarker.type | (() => LazyList[A]^) /* EmptyMarker.type | () => LazyList[A] */) | |
| > extends Iterable[A] | |
| > with collection.SeqOps[A, LazyList, LazyList[A]] | |
| 275c274 | |
| < with Serializable { | |
| --- | |
| > with Serializable { self: LazyList[A]^ => | |
| 280c279 | |
| < private def this(head: A, tail: LazyList[A]) = { | |
| --- | |
| > private def this(head: A, tail: LazyList[A]^) = { | |
| 283c282 | |
| < _tail = tail | |
| --- | |
| > _tail = caps.unsafe.unsafeAssumePure(tail) // SAFETY: we initialize LazyList capturing tail | |
| 299c298 | |
| < private var _tail: AnyRef | Null /* () => LazyList[A] | MidEvaluation.type | LazyList[A] | Null */ = | |
| --- | |
| > private var _tail: AnyRef^{this} | Null /* () => LazyList[A] | MidEvaluation.type | LazyList[A] | Null */ = | |
| 303c302 | |
| < private def rawTail: AnyRef | Null = _tail | |
| --- | |
| > private def rawTail: AnyRef^{this} | Null = _tail | |
| 315c314 | |
| < val fun = _tail.asInstanceOf[() => LazyList[A]] | |
| --- | |
| > val fun = _tail.asInstanceOf[() ->{this} LazyList[A]^{this}] | |
| 330c329 | |
| < @tailrec private def evaluated: LazyList[A] = | |
| --- | |
| > @tailrec private def evaluated: LazyList[A]^{this} = | |
| 339c338 | |
| < override def iterableFactory: SeqFactory[LazyList] = LazyList | |
| --- | |
| > override def iterableFactory: IterableFactory[LazyList] = LazyList | |
| 356c355 | |
| < override def tail: LazyList[A] = | |
| --- | |
| > override def tail: LazyList[A]^{this} = | |
| 360a360,381 | |
| > /* Same implementation as of LinearSeq */ | |
| > override def length: Int = { | |
| > var these: LazyList[A]^{this} = coll | |
| > var len = 0 | |
| > while (these.nonEmpty) { | |
| > len += 1 | |
| > these = these.tail | |
| > } | |
| > len | |
| > } | |
| > | |
| > /* Same implementation as of LinearSeq */ | |
| > // `apply` is defined in terms of `drop`, which is in turn defined in | |
| > // terms of `tail`. | |
| > @throws[IndexOutOfBoundsException] | |
| > override def apply(n: Int): A = { | |
| > if (n < 0) throw new IndexOutOfBoundsException(n.toString) | |
| > val skipped = drop(n) | |
| > if (skipped.isEmpty) throw new IndexOutOfBoundsException(n.toString) | |
| > skipped.head | |
| > } | |
| > | |
| 385c406 | |
| < var these, those: LazyList[A] = this | |
| --- | |
| > var these, those: LazyList[A]^{this} = this | |
| 405c426 | |
| < override def iterator: Iterator[A] = | |
| --- | |
| > override def iterator: Iterator[A]^{this} = | |
| 442c463 | |
| < protected def writeReplace(): AnyRef = | |
| --- | |
| > protected def writeReplace(): AnyRef^{this} = | |
| 456c477 | |
| < def lazyAppendedAll[B >: A](suffix: => collection.IterableOnce[B]): LazyList[B] = | |
| --- | |
| > def lazyAppendedAll[B >: A](suffix: => collection.IterableOnce[B]^): LazyList[B]^{this, suffix} = | |
| 472c493 | |
| < override def appendedAll[B >: A](suffix: IterableOnce[B]): LazyList[B] = | |
| --- | |
| > override def appendedAll[B >: A](suffix: IterableOnce[B]^): LazyList[B]^{this, suffix} = | |
| 482c503 | |
| < override def appended[B >: A](elem: B): LazyList[B] = | |
| --- | |
| > override def appended[B >: A](elem: B): LazyList[B]^{this} = | |
| 490c511 | |
| < override def scanLeft[B](z: B)(op: (B, A) => B): LazyList[B] = | |
| --- | |
| > override def scanLeft[B](z: B)(op: (B, A) => B): LazyList[B]^{this, op} = | |
| 494c515 | |
| < private def scanLeftImpl[B](z: B)(op: (B, A) => B): LazyList[B] = | |
| --- | |
| > private def scanLeftImpl[B](z: B)(op: (B, A) => B): LazyList[B]^{this, op} = | |
| 514c535 | |
| < var left: LazyList[A] = tail | |
| --- | |
| > var left: LazyList[A]^{this} = tail | |
| 527c548 | |
| < override def partition(p: A => Boolean): (LazyList[A], LazyList[A]) = (filter(p), filterNot(p)) | |
| --- | |
| > override def partition(p: A => Boolean): (LazyList[A]^{this, p}, LazyList[A]^{this, p}) = (filter(p), filterNot(p)) | |
| 533,535c554,556 | |
| < override def partitionMap[A1, A2](f: A => Either[A1, A2]): (LazyList[A1], LazyList[A2]) = { | |
| < val (left, right) = map(f).partition(_.isLeft) | |
| < (left.map(_.asInstanceOf[Left[A1, ?]].value), right.map(_.asInstanceOf[Right[?, A2]].value)) | |
| --- | |
| > override def partitionMap[A1, A2](f: A => Either[A1, A2]): (LazyList[A1]^{this, f}, LazyList[A2]^{this, f}) = { | |
| > val p: (LazyList[Either[A1, A2]]^{this, f}, LazyList[Either[A1, A2]]^{this, f}) = map(f).partition(_.isLeft) | |
| > (p._1.map(_.asInstanceOf[Left[A1, ?]].value), p._2.map(_.asInstanceOf[Right[?, A2]].value)) | |
| 542c563 | |
| < override def filter(pred: A => Boolean): LazyList[A] = | |
| --- | |
| > override def filter(pred: A => Boolean): LazyList[A]^{this, pred} = | |
| 550c571 | |
| < override def filterNot(pred: A => Boolean): LazyList[A] = | |
| --- | |
| > override def filterNot(pred: A => Boolean): LazyList[A]^{this, pred} = | |
| 562c583 | |
| < override def withFilter(p: A => Boolean): collection.WithFilter[A, LazyList] = | |
| --- | |
| > override def withFilter(p: A => Boolean): collection.WithFilter[A, LazyList]^{this, p} = | |
| 569c590 | |
| < override def prepended[B >: A](elem: B): LazyList[B] = eagerCons(elem, this) | |
| --- | |
| > override def prepended[B >: A](elem: B): LazyList[B]^{this} = eagerCons(elem, this) | |
| 575c596 | |
| < override def prependedAll[B >: A](prefix: collection.IterableOnce[B]): LazyList[B] = | |
| --- | |
| > override def prependedAll[B >: A](prefix: collection.IterableOnce[B]^): LazyList[B]^{this, prefix} = | |
| 584c605 | |
| < override def map[B](f: A => B): LazyList[B] = | |
| --- | |
| > override def map[B](f: A => B): LazyList[B]^{this, f} = | |
| 592c613 | |
| < override def tapEach[U](f: A => U): LazyList[A] = map { a => f(a); a } | |
| --- | |
| > override def tapEach[U](f: A => U): LazyList[A]^{this, f} = map { a => f(a); a } | |
| 594c615 | |
| < private def mapImpl[B](f: A => B): LazyList[B] = | |
| --- | |
| > private def mapImpl[B](f: A => B): LazyList[B]^{this, f} = | |
| 604c625 | |
| < override def collect[B](pf: PartialFunction[A, B]): LazyList[B] = | |
| --- | |
| > override def collect[B](pf: PartialFunction[A, B]^): LazyList[B]^{this, pf} = | |
| 614c635 | |
| < override def collectFirst[B](pf: PartialFunction[A, B]): Option[B] = | |
| --- | |
| > override def collectFirst[B](pf: PartialFunction[A, B]^): Option[B] = | |
| 642c663 | |
| < override def flatMap[B](f: A => IterableOnce[B]): LazyList[B] = | |
| --- | |
| > override def flatMap[B](f: A => IterableOnce[B]^): LazyList[B]^{this, f} = | |
| 650c671 | |
| < override def flatten[B](implicit asIterable: A => IterableOnce[B]): LazyList[B] = flatMap(asIterable) | |
| --- | |
| > override def flatten[B](implicit asIterable: A -> IterableOnce[B]): LazyList[B]^{this} = flatMap(asIterable) | |
| 656c677 | |
| < override def zip[B](that: collection.IterableOnce[B]): LazyList[(A, B)] = | |
| --- | |
| > override def zip[B](that: collection.IterableOnce[B]^): LazyList[(A, B)]^{this, that} = | |
| 660c681 | |
| < private def eagerHeadZipImpl[B](it: Iterator[B]): LazyList[(A, B)] = | |
| --- | |
| > private def eagerHeadZipImpl[B](it: Iterator[B]^): LazyList[(A, B)]^{this, it} = | |
| 668c689 | |
| < override def zipWithIndex: LazyList[(A, Int)] = this zip LazyList.from(0) | |
| --- | |
| > override def zipWithIndex: LazyList[(A, Int)]^{this} = this zip LazyList.from(0) | |
| 674c695 | |
| < override def zipAll[A1 >: A, B](that: collection.Iterable[B], thisElem: A1, thatElem: B): LazyList[(A1, B)] = { | |
| --- | |
| > override def zipAll[A1 >: A, B](that: collection.Iterable[B]^, thisElem: A1, thatElem: B): LazyList[(A1, B)]^{this, that} = { | |
| 684c705 | |
| < private def eagerHeadZipAllImpl[A1 >: A, B](it: Iterator[B], thisElem: A1, thatElem: B): LazyList[(A1, B)] = { | |
| --- | |
| > private def eagerHeadZipAllImpl[A1 >: A, B](it: Iterator[B]^, thisElem: A1, thatElem: B): LazyList[(A1, B)]^{this, it} = { | |
| 703c724 | |
| < override def lazyZip[B](that: collection.Iterable[B]): LazyZip2[A, B, this.type] = | |
| --- | |
| > override def lazyZip[B](that: collection.Iterable[B]^): LazyZip2[A, B, this.type]^{this, that} = | |
| 710c731 | |
| < override def unzip[A1, A2](implicit asPair: A => (A1, A2)): (LazyList[A1], LazyList[A2]) = | |
| --- | |
| > override def unzip[A1, A2](implicit asPair: A -> (A1, A2)): (LazyList[A1]^{this}, LazyList[A2]^{this}) = | |
| 717c738 | |
| < override def unzip3[A1, A2, A3](implicit asTriple: A => (A1, A2, A3)): (LazyList[A1], LazyList[A2], LazyList[A3]) = | |
| --- | |
| > override def unzip3[A1, A2, A3](implicit asTriple: A -> (A1, A2, A3)): (LazyList[A1]^{this}, LazyList[A2]^{this}, LazyList[A3]^{this}) = | |
| 725c746 | |
| < override def drop(n: Int): LazyList[A] = | |
| --- | |
| > override def drop(n: Int): LazyList[A]^{this} = | |
| 735c756 | |
| < override def dropWhile(p: A => Boolean): LazyList[A] = | |
| --- | |
| > override def dropWhile(p: A => Boolean): LazyList[A]^{this, p} = | |
| 743c764 | |
| < override def dropRight(n: Int): LazyList[A] = { | |
| --- | |
| > override def dropRight(n: Int): LazyList[A]^{this} = { | |
| 747c768 | |
| < var scout = this | |
| --- | |
| > var scout: LazyList[A]^{this} = this | |
| 758c779 | |
| < private def eagerHeadDropRightImpl(scout: LazyList[?]): LazyList[A] = | |
| --- | |
| > private def eagerHeadDropRightImpl(scout: LazyList[?]^): LazyList[A]^{this, scout} = | |
| 766c787 | |
| < override def take(n: Int): LazyList[A] = | |
| --- | |
| > override def take(n: Int): LazyList[A]^{this} = | |
| 770c791 | |
| < private def takeImpl(n: Int): LazyList[A] = { | |
| --- | |
| > private def takeImpl(n: Int): LazyList[A]^{this} = { | |
| 782c803 | |
| < override def takeWhile(p: A => Boolean): LazyList[A] = | |
| --- | |
| > override def takeWhile(p: A => Boolean): LazyList[A]^{this, p} = | |
| 786c807 | |
| < private def takeWhileImpl(p: A => Boolean): LazyList[A] = | |
| --- | |
| > private def takeWhileImpl(p: A => Boolean): LazyList[A]^{this, p} = | |
| 796c817 | |
| < override def takeRight(n: Int): LazyList[A] = | |
| --- | |
| > override def takeRight(n: Int): LazyList[A]^{this} = | |
| 805c826 | |
| < override def slice(from: Int, until: Int): LazyList[A] = take(until).drop(from) | |
| --- | |
| > override def slice(from: Int, until: Int): LazyList[A]^{this} = take(until).drop(from) | |
| 811c832 | |
| < override def reverse: LazyList[A] = reverseOnto(Empty) | |
| --- | |
| > override def reverse: LazyList[A]^{this} = reverseOnto(Empty) | |
| 815c836 | |
| < private def reverseOnto[B >: A](tl: LazyList[B]): LazyList[B] = | |
| --- | |
| > private def reverseOnto[B >: A](tl: LazyList[B]^): LazyList[B]^{this, tl} = | |
| 823c844 | |
| < override def diff[B >: A](that: collection.Seq[B]): LazyList[A] = | |
| --- | |
| > override def diff[B >: A](that: collection.Seq[B]): LazyList[A]^{this} = | |
| 831c852 | |
| < override def intersect[B >: A](that: collection.Seq[B]): LazyList[A] = | |
| --- | |
| > override def intersect[B >: A](that: collection.Seq[B]): LazyList[A]^{this} = | |
| 846c867 | |
| < override def grouped(size: Int): Iterator[LazyList[A]] = { | |
| --- | |
| > override def grouped(size: Int): Iterator[LazyList[A]^{this}]^{this} = { | |
| 856c877 | |
| < override def sliding(size: Int, step: Int): Iterator[LazyList[A]] = { | |
| --- | |
| > override def sliding(size: Int, step: Int): Iterator[LazyList[A]^{this}]^{this} = { | |
| 861c882 | |
| < @inline private def slidingImpl(size: Int, step: Int): Iterator[LazyList[A]] = | |
| --- | |
| > @inline private def slidingImpl(size: Int, step: Int): Iterator[LazyList[A]^{this}]^{this} = | |
| 863c884,886 | |
| < else new SlidingIterator[A](this, size = size, step = step) | |
| --- | |
| > else | |
| > val it = new SlidingIterator[A](this, size = size, step = step) | |
| > it.asInstanceOf[Iterator[Nothing]] // CC cannot figure this out yet | |
| 869c892 | |
| < override def padTo[B >: A](len: Int, elem: B): LazyList[B] = | |
| --- | |
| > override def padTo[B >: A](len: Int, elem: B): LazyList[B]^{this} = | |
| 880c903 | |
| < override def patch[B >: A](from: Int, other: IterableOnce[B], replaced: Int): LazyList[B] = | |
| --- | |
| > override def patch[B >: A](from: Int, other: IterableOnce[B]^, replaced: Int): LazyList[B]^{this, other} = | |
| 884c907 | |
| < private def patchImpl[B >: A](from: Int, other: IterableOnce[B], replaced: Int): LazyList[B] = | |
| --- | |
| > private def patchImpl[B >: A](from: Int, other: IterableOnce[B]^, replaced: Int): LazyList[B]^{this, other} = | |
| 896c919 | |
| < override def transpose[B](implicit asIterable: A => collection.Iterable[B]): LazyList[LazyList[B]] = super.transpose | |
| --- | |
| > override def transpose[B](implicit asIterable: A -> collection.Iterable[B]): LazyList[LazyList[B]^{this}]^{this} = super.transpose | |
| 902c925 | |
| < override def updated[B >: A](index: Int, elem: B): LazyList[B] = | |
| --- | |
| > override def updated[B >: A](index: Int, elem: B): LazyList[B]^{this} = | |
| 906c929 | |
| < private def updatedImpl[B >: A](index: Int, elem: B, startIndex: Int): LazyList[B] = | |
| --- | |
| > private def updatedImpl[B >: A](index: Int, elem: B, startIndex: Int): LazyList[B]^{this} = | |
| 939c962 | |
| < var cursor = this | |
| --- | |
| > var cursor: LazyList[A]^{this} = this | |
| 941,942c964,965 | |
| < @inline def appendHead(c: LazyList[A]): Unit = b.append(sep).append(c.head) | |
| < var scout = tail | |
| --- | |
| > @inline def appendHead(c: LazyList[A]^): Unit = b.append(sep).append(c.head) | |
| > var scout: LazyList[A]^{this} = tail | |
| 975c998 | |
| < var runner = this | |
| --- | |
| > var runner: LazyList[A]^{this} = this | |
| 1024,1025c1047,1048 | |
| < var those = this | |
| < var these = tail | |
| --- | |
| > var those: LazyList[A]^{this} = this | |
| > var these: LazyList[A]^{this} = tail | |
| 1047c1070 | |
| < object LazyList extends SeqFactory[LazyList] { | |
| --- | |
| > object LazyList extends IterableFactory[LazyList] { | |
| 1060c1083 | |
| < @inline private def newLL[A](state: => LazyList[A]): LazyList[A] = new LazyList[A](() => state) | |
| --- | |
| > @inline private def newLL[A](state: => LazyList[A]^): LazyList[A]^{state} = new LazyList[A](() => state) | |
| 1063c1086 | |
| < @inline private def eagerCons[A](hd: A, tl: LazyList[A]): LazyList[A] = new LazyList[A](hd, tl) | |
| --- | |
| > @inline private def eagerCons[A](hd: A, tl: LazyList[A]^): LazyList[A]^{tl} = new LazyList[A](hd, tl) | |
| 1065c1088 | |
| < private val anyToMarker: Any => Any = _ => Statics.pfMarker | |
| --- | |
| > private val anyToMarker: Any -> Any = _ => Statics.pfMarker | |
| 1075c1098 | |
| < private def filterImpl[A](ll: LazyList[A], p: A => Boolean, isFlipped: Boolean): LazyList[A] = { | |
| --- | |
| > private def filterImpl[A](ll: LazyList[A]^, p: A => Boolean, isFlipped: Boolean): LazyList[A]^{ll, p} = { | |
| 1077c1100 | |
| < var restRef = ll // val restRef = new ObjectRef(ll) | |
| --- | |
| > var restRef: LazyList[A]^{ll} = ll // val restRef = new ObjectRef(ll) | |
| 1080,1081c1103,1104 | |
| < var found = false | |
| < var rest = restRef // var rest = restRef.elem | |
| --- | |
| > var found = false | |
| > var rest: LazyList[A]^{ll} = restRef // var rest = restRef.elem | |
| 1092c1115 | |
| < private def collectImpl[A, B](ll: LazyList[A], pf: PartialFunction[A, B]): LazyList[B] = { | |
| --- | |
| > private def collectImpl[A, B](ll: LazyList[A]^, pf: PartialFunction[A, B]^): LazyList[B]^{ll, pf} = { | |
| 1094c1117 | |
| < var restRef = ll // val restRef = new ObjectRef(ll) | |
| --- | |
| > var restRef: LazyList[A]^{ll} = ll // val restRef = new ObjectRef(ll) | |
| 1100c1123 | |
| < var rest = restRef // var rest = restRef.elem | |
| --- | |
| > var rest: LazyList[A]^{ll} = restRef // var rest = restRef.elem | |
| 1111c1134 | |
| < private def flatMapImpl[A, B](ll: LazyList[A], f: A => IterableOnce[B]): LazyList[B] = { | |
| --- | |
| > private def flatMapImpl[A, B](ll: LazyList[A]^, f: A => IterableOnce[B]^): LazyList[B]^{ll, f} = { | |
| 1113c1136 | |
| < var restRef = ll // val restRef = new ObjectRef(ll) | |
| --- | |
| > var restRef: LazyList[A]^{ll} = ll // val restRef = new ObjectRef(ll) | |
| 1115,1117c1138,1140 | |
| < var it: Iterator[B] | Null = null | |
| < var itHasNext = false | |
| < var rest = restRef // var rest = restRef.elem | |
| --- | |
| > var it: Iterator[B]^{f} | Null = null | |
| > var itHasNext = false | |
| > var rest: LazyList[A]^{ll} = restRef // var rest = restRef.elem | |
| 1135c1158 | |
| < private def dropImpl[A](ll: LazyList[A], n: Int): LazyList[A] = { | |
| --- | |
| > private def dropImpl[A](ll: LazyList[A]^, n: Int): LazyList[A]^{ll} = { | |
| 1137,1138c1160,1161 | |
| < var restRef = ll // val restRef = new ObjectRef(ll) | |
| < var iRef = n // val iRef = new IntRef(n) | |
| --- | |
| > var restRef: LazyList[A]^{ll} = ll // val restRef = new ObjectRef(ll) | |
| > var iRef = n // val iRef = new IntRef(n) | |
| 1140,1141c1163,1164 | |
| < var rest = restRef // var rest = restRef.elem | |
| < var i = iRef // var i = iRef.elem | |
| --- | |
| > var rest: LazyList[A]^{ll} = restRef // var rest = restRef.elem | |
| > var i = iRef // var i = iRef.elem | |
| 1152c1175 | |
| < private def dropWhileImpl[A](ll: LazyList[A], p: A => Boolean): LazyList[A] = { | |
| --- | |
| > private def dropWhileImpl[A](ll: LazyList[A]^, p: A => Boolean): LazyList[A]^{ll, p} = { | |
| 1154c1177 | |
| < var restRef = ll // val restRef = new ObjectRef(ll) | |
| --- | |
| > var restRef: LazyList[A]^{ll} = ll // val restRef = new ObjectRef(ll) | |
| 1156c1179 | |
| < var rest = restRef // var rest = restRef.elem | |
| --- | |
| > var rest: LazyList[A]^{ll} = restRef // var rest = restRef.elem | |
| 1165c1188 | |
| < private def takeRightImpl[A](ll: LazyList[A], n: Int): LazyList[A] = { | |
| --- | |
| > private def takeRightImpl[A](ll: LazyList[A]^, n: Int): LazyList[A]^{ll} = { | |
| 1167,1169c1190,1192 | |
| < var restRef = ll // val restRef = new ObjectRef(ll) | |
| < var scoutRef = ll // val scoutRef = new ObjectRef(ll) | |
| < var remainingRef = n // val remainingRef = new IntRef(n) | |
| --- | |
| > var restRef: LazyList[A]^{ll} = ll // val restRef = new ObjectRef(ll) | |
| > var scoutRef: LazyList[A]^{ll} = ll // val scoutRef = new ObjectRef(ll) | |
| > var remainingRef = n // val remainingRef = new IntRef(n) | |
| 1171,1172c1194,1195 | |
| < var scout = scoutRef // var scout = scoutRef.elem | |
| < var remaining = remainingRef // var remaining = remainingRef.elem | |
| --- | |
| > var scout: LazyList[A]^{ll} = scoutRef // var scout = scoutRef.elem | |
| > var remaining = remainingRef // var remaining = remainingRef.elem | |
| 1176c1199 | |
| < scoutRef = scout // scoutRef.elem = scout | |
| --- | |
| > scoutRef = scout // scoutRef.elem = scout | |
| 1178c1201 | |
| < remainingRef = remaining // remainingRef.elem = remaining | |
| --- | |
| > remainingRef = remaining // remainingRef.elem = remaining | |
| 1180c1203 | |
| < var rest = restRef // var rest = restRef.elem | |
| --- | |
| > var rest: LazyList[A]^{ll} = restRef // var rest = restRef.elem | |
| 1200c1223 | |
| < def apply[A](hd: => A, tl: => LazyList[A]): LazyList[A] = newLL(eagerCons(hd, newLL(tl))) | |
| --- | |
| > def apply[A](hd: => A, tl: => LazyList[A]): LazyList[A]^{hd, tl} = newLL(eagerCons(hd, newLL(tl))) | |
| 1203c1226 | |
| < def unapply[A](xs: LazyList[A]): Option[(A, LazyList[A])] = #::.unapply(xs) | |
| --- | |
| > def unapply[A](xs: LazyList[A]^): Option[(A, LazyList[A]^{xs})] = #::.unapply(xs) | |
| 1206c1229 | |
| < implicit def toDeferrer[A](l: => LazyList[A]): Deferrer[A] = new Deferrer[A](() => l) | |
| --- | |
| > implicit def toDeferrer[A](l: => LazyList[A]^): Deferrer[A]^{l} = new Deferrer[A](() => l) | |
| 1208c1231 | |
| < final class Deferrer[A] private[LazyList] (private val l: () => LazyList[A]) extends AnyVal { | |
| --- | |
| > final class Deferrer[A] private[LazyList] (private val l: () => LazyList[A]^) extends AnyVal { self: Deferrer[A]^ => | |
| 1212c1235 | |
| < def #:: [B >: A](elem: => B): LazyList[B] = newLL(eagerCons(elem, newLL(l()))) | |
| --- | |
| > def #:: [B >: A](elem: => B): LazyList[B]^{this, elem} = newLL(eagerCons(elem, newLL(l()))) | |
| 1216c1239 | |
| < def #:::[B >: A](prefix: LazyList[B]): LazyList[B] = prefix lazyAppendedAll l() | |
| --- | |
| > def #:::[B >: A](prefix: LazyList[B]^): LazyList[B]^{this, prefix} = prefix lazyAppendedAll l() | |
| 1220c1243 | |
| < def unapply[A](s: LazyList[A]): Option[(A, LazyList[A])] = | |
| --- | |
| > def unapply[A](s: LazyList[A]^): Option[(A, LazyList[A]^{s})] = | |
| 1224c1247 | |
| < def from[A](coll: collection.IterableOnce[A]): LazyList[A] = coll match { | |
| --- | |
| > def from[A](coll: collection.IterableOnce[A]^): LazyList[A]^{coll} = coll match { | |
| 1235c1258 | |
| < private def eagerHeadPrependIterator[A](it: Iterator[A])(suffix: => LazyList[A]): LazyList[A] = | |
| --- | |
| > private def eagerHeadPrependIterator[A](it: Iterator[A]^)(suffix: => LazyList[A]^): LazyList[A]^{it, suffix} = | |
| 1240c1263 | |
| < private def eagerHeadFromIterator[A](it: Iterator[A]): LazyList[A] = | |
| --- | |
| > private def eagerHeadFromIterator[A](it: Iterator[A]^): LazyList[A]^{it} = | |
| 1243a1267 | |
| > // TODO This should be (xss: (collection.Iterable[A]^)*) | |
| 1248,1250c1272,1279 | |
| < private def eagerHeadConcatIterators[A](it: Iterator[collection.Iterable[A]]): LazyList[A] = | |
| < if (!it.hasNext) Empty | |
| < else eagerHeadPrependIterator(it.next().iterator)(eagerHeadConcatIterators(it)) | |
| --- | |
| > /* TODO This should be: | |
| > private def eagerHeadConcatIterators[A](it: Iterator[collection.Iterable[A]^]^): LazyList[A]^{it*} = | |
| > if !it.hasNext then Empty | |
| > else | |
| > eagerHeadPrependIterator | |
| > (caps.unsafe.unsafeDiscardUses(it.next()).iterator) | |
| > (eagerHeadConcatIterators(it)) | |
| > */ | |
| 1251a1281,1287 | |
| > private def eagerHeadConcatIterators[A](it: Iterator[collection.Iterable[A]]^): LazyList[A]^{it} = | |
| > if !it.hasNext then Empty | |
| > else | |
| > eagerHeadPrependIterator | |
| > (it.next().iterator) | |
| > (eagerHeadConcatIterators(it)) | |
| > | |
| 1258c1294 | |
| < def iterate[A](start: => A)(f: A => A): LazyList[A] = | |
| --- | |
| > def iterate[A](start: => A)(f: A => A): LazyList[A]^{start, f} = | |
| 1290c1326 | |
| < def continually[A](elem: => A): LazyList[A] = newLL(eagerCons(elem, continually(elem))) | |
| --- | |
| > def continually[A](elem: => A): LazyList[A]^{elem} = newLL(eagerCons(elem, continually(elem))) | |
| 1292c1328 | |
| < override def fill[A](n: Int)(elem: => A): LazyList[A] = | |
| --- | |
| > override def fill[A](n: Int)(elem: => A): LazyList[A]^{elem} = | |
| 1295,1296c1331,1332 | |
| < override def tabulate[A](n: Int)(f: Int => A): LazyList[A] = { | |
| < def at(index: Int): LazyList[A] = | |
| --- | |
| > override def tabulate[A](n: Int)(f: Int => A): LazyList[A]^{f} = { | |
| > def at(index: Int): LazyList[A]^{f} = | |
| 1303c1339 | |
| < override def unfold[A, S](init: S)(f: S => Option[(A, S)]): LazyList[A] = | |
| --- | |
| > override def unfold[A, S](init: S)(f: S => Option[(A, S)]): LazyList[A]^{f} = | |
| 1311,1312c1347,1349 | |
| < /** The builder returned by this method only evaluates elements | |
| < * of collections added to it as needed. | |
| --- | |
| > /** Unlike LazyList, the builder returned by this method will eagerly evaluate all elements | |
| > * passed to it in `addAll`. | |
| > * To create a LazyList from an IterableOnce, use `fromSpecific`. | |
| 1317c1354 | |
| < def newBuilder[A]: Builder[A, LazyList[A]] = new LazyBuilder[A] | |
| --- | |
| > def newBuilder[A]: Builder[A, LazyList[A]] = (new collection.mutable.ListBuffer[A]).mapResult(from) | |
| 1319c1356 | |
| < private class LazyIterator[+A](private var lazyList: LazyList[A]) extends AbstractIterator[A] { | |
| --- | |
| > private class LazyIterator[+A](private var lazyList: LazyList[A]^) extends AbstractIterator[A] { | |
| 1331,1332c1368,1370 | |
| < private class SlidingIterator[A](private var lazyList: LazyList[A], size: Int, step: Int) | |
| < extends AbstractIterator[LazyList[A]] { | |
| --- | |
| > private class SlidingIterator[A](l: LazyList[A]^, size: Int, step: Int) | |
| > extends AbstractIterator[LazyList[A]^{l}] { | |
| > private var lazyList: LazyList[A]^{l} = l | |
| 1340c1378 | |
| < def next(): LazyList[A] = { | |
| --- | |
| > def next(): LazyList[A]^{l} = { | |
| 1351c1389 | |
| < private final class WithFilter[A] private[LazyList](lazyList: LazyList[A], p: A => Boolean) | |
| --- | |
| > private final class WithFilter[A] private[LazyList](lazyList: LazyList[A]^, p: A => Boolean) | |
| 1353,1355c1391,1393 | |
| < private val filtered = lazyList.filter(p) | |
| < def map[B](f: A => B): LazyList[B] = filtered.map(f) | |
| < def flatMap[B](f: A => IterableOnce[B]): LazyList[B] = filtered.flatMap(f) | |
| --- | |
| > @untrackedCaptures private val filtered = lazyList.filter(p) | |
| > def map[B](f: A => B): LazyList[B]^{this, f} = filtered.map(f) | |
| > def flatMap[B](f: A => IterableOnce[B]^): LazyList[B]^{this, f} = filtered.flatMap(f) | |
| 1357c1395 | |
| < def withFilter(q: A => Boolean): collection.WithFilter[A, LazyList] = new WithFilter(filtered, q) | |
| --- | |
| > def withFilter(q: A => Boolean): collection.WithFilter[A, LazyList]^{this, q} = new WithFilter(filtered, q) | |
| 1360,1361c1398 | |
| < private final class LazyBuilder[A] extends ReusableBuilder[A, LazyList[A]] { | |
| < import LazyBuilder._ | |
| --- | |
| > // CC Note: Lazy Builder is not unsafe, but requires an explicit capture set. | |
| 1363,1366c1400,1401 | |
| < private var next: DeferredState[A] = compiletime.uninitialized | |
| < private var list: LazyList[A] = compiletime.uninitialized | |
| < | |
| < clear() | |
| --- | |
| > // private final class LazyBuilder[A, Cap^] extends ReusableBuilder[A, LazyList[A]] { | |
| > // import LazyBuilder._ | |
| 1368,1372c1403,1404 | |
| < override def clear(): Unit = { | |
| < val deferred = new DeferredState[A] | |
| < list = newLL(deferred.eval()) | |
| < next = deferred | |
| < } | |
| --- | |
| > // private[this] var next: DeferredState[A, Cap]^{Cap} = _ | |
| > // private[this] var list: LazyList[A]^{Cap} = _ | |
| 1374,1377c1406 | |
| < override def result(): LazyList[A] = { | |
| < next init Empty | |
| < list | |
| < } | |
| --- | |
| > // clear() | |
| 1379,1384c1408,1412 | |
| < override def addOne(elem: A): this.type = { | |
| < val deferred = new DeferredState[A] | |
| < next init eagerCons(elem, newLL(deferred.eval())) | |
| < next = deferred | |
| < this | |
| < } | |
| --- | |
| > // override def clear(): Unit = { | |
| > // val deferred = new DeferredState[A, Cap] | |
| > // list = newLL(deferred.eval()) | |
| > // next = deferred | |
| > // } | |
| 1386,1395c1414,1417 | |
| < // lazy implementation which doesn't evaluate the collection being added | |
| < override def addAll(xs: IterableOnce[A]): this.type = { | |
| < if (xs.knownSize != 0) { | |
| < val deferred = new DeferredState[A] | |
| < next init eagerHeadPrependIterator(xs.iterator)(deferred.eval()) | |
| < next = deferred | |
| < } | |
| < this | |
| < } | |
| < } | |
| --- | |
| > // override def result(): LazyList[A]^{Cap} = { | |
| > // next init Empty | |
| > // list | |
| > // } | |
| 1397,1399c1419,1424 | |
| < private object LazyBuilder { | |
| < final class DeferredState[A] { | |
| < private var _tail: () => LazyList[A] = compiletime.uninitialized | |
| --- | |
| > // override def addOne(elem: A): this.type = { | |
| > // val deferred = new DeferredState[A, Cap] | |
| > // next init eagerCons(elem, newLL(deferred.eval())) | |
| > // next = deferred | |
| > // this | |
| > // } | |
| 1401,1405c1426,1435 | |
| < def eval(): LazyList[A] = { | |
| < val state = _tail | |
| < if (state == null) throw new IllegalStateException("uninitialized") | |
| < state() | |
| < } | |
| --- | |
| > // // lazy implementation which doesn't evaluate the collection being added | |
| > // override def addAll(xs: IterableOnce[A]^{Cap}): this.type = { | |
| > // if (xs.knownSize != 0) { | |
| > // val deferred = new DeferredState[A, Cap] | |
| > // next init eagerHeadPrependIterator(xs.iterator)(deferred.eval()) | |
| > // next = deferred | |
| > // } | |
| > // this | |
| > // } | |
| > // } | |
| 1407,1413c1437,1439 | |
| < // racy | |
| < def init(state: => LazyList[A]): Unit = { | |
| < if (_tail != null) throw new IllegalStateException("already initialized") | |
| < _tail = () => state | |
| < } | |
| < } | |
| < } | |
| --- | |
| > // private object LazyBuilder { | |
| > // final class DeferredState[A, Cap^] { | |
| > // private[this] var _tail: () ->{Cap} LazyList[A]^{Cap} = _ | |
| 1414a1441,1454 | |
| > // def eval(): LazyList[A]^{Cap} = { | |
| > // val state = _tail | |
| > // if (state == null) throw new IllegalStateException("uninitialized") | |
| > // state() | |
| > // } | |
| > | |
| > // // racy | |
| > // def init(state: ->{Cap} LazyList[A]^{Cap}): Unit = { | |
| > // if (_tail != null) throw new IllegalStateException("already initialized") | |
| > // _tail = () => state | |
| > // } | |
| > // } | |
| > // } | |
| > | |
| 1421c1461,1462 | |
| < final class SerializationProxy[A](@transient protected var coll: LazyList[A]) extends Serializable { | |
| --- | |
| > final class SerializationProxy[A](of: LazyList[A]^) extends Serializable { | |
| > @transient protected var coll: LazyList[A]^{this} = of | |
| 1425c1466 | |
| < var these = coll | |
| --- | |
| > var these: LazyList[A]^{this} = coll | |
| 1452d1492 | |
| < |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment