@@ -181,7 +181,7 @@ sealed abstract class CaptureSet extends Showable:
181
181
/** {x} <:< this where <:< is subcapturing, but treating all variables
182
182
* as frozen.
183
183
*/
184
- def accountsFor (x : CaptureRef )(using ctx : Context , vs : VarState = VarState .Separate ): Boolean =
184
+ def accountsFor (x : CaptureRef )(using ctx : Context )( using vs : VarState = VarState .Separate ): Boolean =
185
185
186
186
def debugInfo (using Context ) = i " $this accountsFor $x, which has capture set ${x.captureSetOfInfo}"
187
187
@@ -210,7 +210,7 @@ sealed abstract class CaptureSet extends Showable:
210
210
def mightAccountFor (x : CaptureRef )(using Context ): Boolean =
211
211
reporting.trace(i " $this mightAccountFor $x, ${x.captureSetOfInfo}? " , show = true ):
212
212
CCState .withCapAsRoot: // OK here since we opportunistically choose an alternative which gets checked later
213
- elems.exists(_.subsumes(x)(using ctx, VarState .ClosedUnrecorded ))
213
+ elems.exists(_.subsumes(x)(using ctx)( using VarState .ClosedUnrecorded ))
214
214
|| ! x.isRootCapability
215
215
&& {
216
216
val elems = x.captureSetOfInfo.elems
@@ -405,8 +405,6 @@ object CaptureSet:
405
405
type Vars = SimpleIdentitySet [Var ]
406
406
type Deps = SimpleIdentitySet [CaptureSet ]
407
407
408
- @ sharable private var varId = 0
409
-
410
408
/** If set to `true`, capture stack traces that tell us where sets are created */
411
409
private final val debugSets = false
412
410
@@ -485,7 +483,7 @@ object CaptureSet:
485
483
object Fluid extends Const (emptyRefs):
486
484
override def isAlwaysEmpty (using Context ) = false
487
485
override def addThisElem (elem : CaptureRef )(using Context , VarState ) = CompareResult .OK
488
- override def accountsFor (x : CaptureRef )(using Context , VarState ): Boolean = true
486
+ override def accountsFor (x : CaptureRef )(using Context )( using VarState ): Boolean = true
489
487
override def mightAccountFor (x : CaptureRef )(using Context ): Boolean = true
490
488
override def toString = " <fluid>"
491
489
end Fluid
@@ -497,8 +495,9 @@ object CaptureSet:
497
495
498
496
/** A unique identification number for diagnostics */
499
497
val id =
500
- varId += 1
501
- varId
498
+ val ccs = ccState
499
+ ccs.varId += 1
500
+ ccs.varId
502
501
503
502
// assert(id != 40)
504
503
@@ -1221,37 +1220,36 @@ object CaptureSet:
1221
1220
* reference `r` only if `r` is already present in the hidden set of the instance.
1222
1221
* No new references can be added.
1223
1222
*/
1224
- @ sharable
1225
- object Separate extends Separating
1223
+ def Separate (using Context ): Separating = ccState.Separate
1226
1224
1227
1225
/** Like Separate but in addition we assume that `cap` never subsumes anything else.
1228
1226
* Used in `++` to not lose track of dependencies between function parameters.
1229
1227
*/
1230
- @ sharable
1231
- object HardSeparate extends Separating
1228
+ def HardSeparate (using Context ): Separating = ccState.HardSeparate
1232
1229
1233
1230
/** A special state that turns off recording of elements. Used only
1234
- * in `addSub` to prevent cycles in recordings.
1231
+ * in `addSub` to prevent cycles in recordings. Instantiated in ccState.Unrecorded.
1235
1232
*/
1236
- @ sharable
1237
- private [CaptureSet ] object Unrecorded extends VarState :
1233
+ class Unrecorded extends VarState :
1238
1234
override def putElems (v : Var , refs : Refs ) = true
1239
1235
override def putDeps (v : Var , deps : Deps ) = true
1240
1236
override def rollBack (): Unit = ()
1241
1237
override def addHidden (hidden : HiddenSet , elem : CaptureRef )(using Context ): Boolean = true
1242
1238
override def toString = " unrecorded varState"
1243
1239
1240
+ def Unrecorded (using Context ): Unrecorded = ccState.Unrecorded
1241
+
1244
1242
/** A closed state that turns off recording of hidden elements (but allows
1245
- * adding them). Used in `mightAccountFor`.
1243
+ * adding them). Used in `mightAccountFor`. Instantiated in ccState.ClosedUnrecorded.
1246
1244
*/
1247
- @ sharable
1248
- private [CaptureSet ] object ClosedUnrecorded extends Closed :
1245
+ class ClosedUnrecorded extends Closed :
1249
1246
override def addHidden (hidden : HiddenSet , elem : CaptureRef )(using Context ): Boolean = true
1250
1247
override def toString = " closed unrecorded varState"
1251
1248
1249
+ def ClosedUnrecorded (using Context ): ClosedUnrecorded = ccState.ClosedUnrecorded
1250
+
1252
1251
end VarState
1253
1252
1254
- @ sharable
1255
1253
/** The current VarState, as passed by the implicit context */
1256
1254
def varState (using state : VarState ): VarState = state
1257
1255
0 commit comments