@@ -26,28 +26,33 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater
2626 * class has access to the corresponding field. So it needs to be called in the class where the field is
2727 * declared (fields are always private in Scala).
2828 */
29- abstract class LazyListIterableBase [+ A ] private [immutable] (initialTail : AnyRef | Null ) extends Iterable [A ] with Serializable {
29+ abstract class LazyListIterableBase [+ A ] private [immutable] (initialTail : ( AnyRef | Null ) ^ ) extends Iterable [A ] with Serializable {
3030 /** See [[LazyList._head ]] for the possible states of this field. */
31- @ volatile private var _tail : AnyRef ^ {this } | Null /* () => LazyList[A] | Thread | InRace | LazyList[A] | Null */ = initialTail
31+ @ volatile private var _tail : AnyRef ^ {this } | Null /* () => LazyList[A] | Thread | InRace | LazyList[A] | Null */ =
32+ caps.unsafe.unsafeAssumePure(initialTail)
3233
3334 private [immutable] def rawTail : AnyRef ^ {this } | Null = _tail
3435
35- private [immutable] def setRawTail (value : AnyRef ): Unit = _tail = value
36+ private [immutable] def setRawTail (value : AnyRef ^ ): Unit = _tail = caps.unsafe.unsafeAssumePure( value)
3637
3738 @ noinline private [immutable] def makeTailUpdater : LazyListIterableBase .TailUpdater =
3839 new LazyListIterableBase .TailUpdater (AtomicReferenceFieldUpdater .newUpdater(classOf [LazyListIterableBase [? ]], classOf [AnyRef ], " _tail" ))
3940}
4041
4142private [immutable] object LazyListIterableBase {
43+ import caps .unsafe .unsafeAssumePure
44+
4245 final class TailUpdater (u : AtomicReferenceFieldUpdater [LazyListIterableBase [? ], AnyRef ]) {
43- def compareAndSet (ll : LazyListIterableBase [? ], expected : AnyRef , value : AnyRef ): Boolean = u.compareAndSet(ll, expected, value)
44- def getAndSet (ll : LazyListIterableBase [? ], value : AnyRef | Null ): AnyRef | Null = u.getAndSet(ll, value)
46+ def compareAndSet (ll : LazyListIterableBase [? ]^ , expected : AnyRef ^ , value : AnyRef ^ ): Boolean =
47+ u.compareAndSet(unsafeAssumePure(ll), unsafeAssumePure(expected), unsafeAssumePure(value))
48+ def getAndSet (ll : LazyListIterableBase [? ]^ , value : (AnyRef | Null )^ ): (AnyRef | Null )^ =
49+ u.getAndSet(unsafeAssumePure(ll), value.asInstanceOf [AnyRef | Null ])
4550 }
4651
4752 // this utility is constant `true` on Scala.js -> enables DCE in LazyList
48- def isCurrentThread (t : Thread ): Boolean = t eq Thread .currentThread
53+ def isCurrentThread (t : Thread ^ ): Boolean = t eq Thread .currentThread
4954 // also for Scala.js
50- def InRace (t : Thread ): InRace = new InRace (t )
55+ def InRace (t : Thread ^ ): InRace = new InRace (unsafeAssumePure(t) )
5156
5257 final class InRace private [LazyListIterableBase ] (val owner : Thread ) {
5358 private val done : CountDownLatch = new CountDownLatch (1 )
0 commit comments