@@ -59,15 +59,15 @@ sealed abstract class CaptureSet extends Showable:
5959 def mutability_= (x : Mutability ): Unit =
6060 myMut = x
6161
62- /** Mark this capture set as belonging to a Mutable type. Called when a new
62+ /** Mark this capture set as belonging to a Stateful type. Called when a new
6363 * CapturingType is formed. This is different from the setter `mutability_=`
64- * in that it be defined with different behaviors:
64+ * in that it can be defined with different behaviors:
6565 *
66- * - set mutability to Mutable (for normal Vars)
66+ * - set mutability to Writer (for normal Vars)
6767 * - take mutability from the set's sources (for DerivedVars)
6868 * - compute mutability on demand based on mutability of elements (for Consts)
6969 */
70- def associateWithMutable ()(using Context ): CaptureSet
70+ def associateWithStateful ()(using Context ): CaptureSet
7171
7272 /** Is this capture set constant (i.e. not an unsolved capture variable)?
7373 * Solved capture variables count as constant.
@@ -191,7 +191,7 @@ sealed abstract class CaptureSet extends Showable:
191191 newElems.forall(tryInclude(_, origin))
192192
193193 protected def mutableToReader (origin : CaptureSet )(using Context ): Boolean =
194- if mutability == Mutable then toReader() else true
194+ if mutability == Writer then toReader() else true
195195
196196 /** Add an element to this capture set, assuming it is not already accounted for,
197197 * and omitting any mapping or filtering.
@@ -315,8 +315,8 @@ sealed abstract class CaptureSet extends Showable:
315315 def adaptMutability (that : CaptureSet )(using Context ): CaptureSet | Null =
316316 val m1 = this .mutability
317317 val m2 = that.mutability
318- if m1 == Mutable && m2 == Reader then this .readOnly
319- else if m1 == Reader && m2 == Mutable then
318+ if m1 == Writer && m2 == Reader then this .readOnly
319+ else if m1 == Reader && m2 == Writer then
320320 if that.toReader() then this else null
321321 else this
322322
@@ -542,13 +542,13 @@ object CaptureSet:
542542 type Deps = SimpleIdentitySet [CaptureSet ]
543543
544544 enum Mutability :
545- case Mutable , Reader , Ignored
545+ case Writer , Reader , Ignored
546546
547547 def | (that : Mutability ): Mutability =
548548 if this == that then this
549549 else if this == Ignored || that == Ignored then Ignored
550550 else if this == Reader || that == Reader then Reader
551- else Mutable
551+ else Writer
552552
553553 def & (that : Mutability ): Mutability =
554554 if this == that then this
@@ -569,9 +569,9 @@ object CaptureSet:
569569 @ sharable // sharable since the set is empty, so mutability won't be set
570570 val empty : CaptureSet .Const = Const (emptyRefs)
571571
572- /** The empty capture set `{}` of a Mutable type, with Reader status */
573- @ sharable // sharable since the set is empty, so mutability won't be set
574- val emptyOfMutable : CaptureSet .Const =
572+ /** The empty capture set `{}` of a Stateful type, with Reader status */
573+ @ sharable // sharable since the set is empty, so mutability won't be re- set
574+ val emptyOfStateful : CaptureSet .Const =
575575 val cs = Const (emptyRefs)
576576 cs.mutability = Mutability .Reader
577577 cs
@@ -630,15 +630,15 @@ object CaptureSet:
630630
631631 private var isComplete = true
632632
633- def associateWithMutable ()(using Context ): CaptureSet =
634- if elems.isEmpty then emptyOfMutable
633+ def associateWithStateful ()(using Context ): CaptureSet =
634+ if elems.isEmpty then emptyOfStateful
635635 else
636636 isComplete = false // delay computation of Mutability status
637637 this
638638
639639 override def mutability (using Context ): Mutability =
640640 if ! isComplete then
641- myMut = if maybeExclusive then Mutable else Reader
641+ myMut = if maybeExclusive then Writer else Reader
642642 isComplete = true
643643 myMut
644644
@@ -652,7 +652,7 @@ object CaptureSet:
652652 else " "
653653
654654 private def capImpliedByCapability (parent : Type )(using Context ): Capability =
655- if parent.derivesFromMutable then GlobalCap .readOnly else GlobalCap
655+ if parent.derivesFromStateful then GlobalCap .readOnly else GlobalCap
656656
657657 /* The same as {cap} but generated implicitly for references of Capability subtypes.
658658 */
@@ -665,13 +665,14 @@ object CaptureSet:
665665 * nulls, this provides more lenient checking against compilation units that
666666 * were not yet compiled with capture checking on.
667667 */
668- @ sharable // sharable since the set is empty, so setMutable is a no-op
668+ @ sharable
669669 object Fluid extends Const (emptyRefs):
670670 override def isAlwaysEmpty (using Context ) = false
671671 override def addThisElem (elem : Capability )(using Context , VarState ) = true
672672 override def toReader ()(using Context ) = true
673673 override def accountsFor (x : Capability )(using Context )(using VarState ): Boolean = true
674674 override def mightAccountFor (x : Capability )(using Context ): Boolean = true
675+ override def mutability_= (x : Mutability ): Unit = ()
675676 override def toString = " <fluid>"
676677 end Fluid
677678
@@ -727,8 +728,8 @@ object CaptureSet:
727728 */
728729 var deps : Deps = SimpleIdentitySet .empty
729730
730- def associateWithMutable ()(using Context ): CaptureSet =
731- mutability = Mutable
731+ def associateWithStateful ()(using Context ): CaptureSet =
732+ mutability = Writer
732733 this
733734
734735 def isConst (using Context ) = solved >= ccState.iterationId
@@ -846,7 +847,7 @@ object CaptureSet:
846847 if isConst then failWith(MutAdaptFailure (this ))
847848 else
848849 mutability = Reader
849- TypeComparer .logUndoAction(() => mutability = Mutable )
850+ TypeComparer .logUndoAction(() => mutability = Writer )
850851 deps.forall(_.mutableToReader(this ))
851852
852853 private def isPartOf (binder : Type )(using Context ): Boolean =
@@ -933,7 +934,7 @@ object CaptureSet:
933934 def markSolved (provisional : Boolean )(using Context ): Unit =
934935 solved = if provisional then ccState.iterationId else Int .MaxValue
935936 deps.foreach(_.propagateSolved(provisional))
936- if mutability == Mutable && ! maybeExclusive then mutability = Reader
937+ if mutability == Writer && ! maybeExclusive then mutability = Reader
937938
938939
939940 var skippedMaps : Set [TypeMap ] = Set .empty
@@ -1046,7 +1047,7 @@ object CaptureSet:
10461047 addAsDependentTo(source)
10471048
10481049 /** Mutability is same as in source, except for readOnly */
1049- override def associateWithMutable ()(using Context ): CaptureSet = this
1050+ override def associateWithStateful ()(using Context ): CaptureSet = this
10501051
10511052 override def mutableToReader (origin : CaptureSet )(using Context ): Boolean =
10521053 super .mutableToReader(origin)
@@ -1175,8 +1176,8 @@ object CaptureSet:
11751176 super .mutableToReader(origin)
11761177 && {
11771178 if (origin eq cs1) || (origin eq cs2) then true
1178- else if cs1.isConst && cs1.mutability == Mutable then cs2.mutableToReader(this )
1179- else if cs2.isConst && cs2.mutability == Mutable then cs1.mutableToReader(this )
1179+ else if cs1.isConst && cs1.mutability == Writer then cs2.mutableToReader(this )
1180+ else if cs2.isConst && cs2.mutability == Writer then cs1.mutableToReader(this )
11801181 else true
11811182 }
11821183
@@ -1403,7 +1404,7 @@ object CaptureSet:
14031404 else i " $elem cannot be included in $cs"
14041405 end IncludeFailure
14051406
1406- /** Failure indicating that a read-only capture set of a mutable type cannot be
1407+ /** Failure indicating that a read-only capture set of a stateful type cannot be
14071408 * widened to an exclusive set.
14081409 * @param cs the exclusive set in question
14091410 * @param lo the lower type of the orginal type comparison, or NoType if not known
@@ -1412,7 +1413,7 @@ object CaptureSet:
14121413 case class MutAdaptFailure (cs : CaptureSet , lo : Type = NoType , hi : Type = NoType ) extends Note :
14131414
14141415 def render (using Context ): String =
1415- def ofType (tp : Type ) = if tp.exists then i " of the mutable type $tp" else " of a mutable type"
1416+ def ofType (tp : Type ) = if tp.exists then i " of the stateful type $tp" else " of a stateful type"
14161417 i """
14171418 |
14181419 |Note that $cs is an exclusive capture set ${ofType(hi)},
0 commit comments