@@ -512,17 +512,13 @@ object CaptureSet:
512
512
val emptyRefs : Refs = SimpleIdentitySet .empty
513
513
514
514
/** The empty capture set `{}` */
515
+ @ sharable // sharable since the set is empty, so setMutable is a no-op
515
516
val empty : CaptureSet .Const = Const (emptyRefs)
516
517
517
518
/** The universal capture set `{cap}` */
518
519
def universal (using Context ): Const =
519
520
Const (SimpleIdentitySet (GlobalCap ))
520
521
521
- /** The same as {cap.rd} but generated implicitly for
522
- * references of Capability subtypes
523
- */
524
- val csImpliedByCapability = Const (SimpleIdentitySet (GlobalCap .readOnly))
525
-
526
522
def fresh (origin : Origin )(using Context ): Const =
527
523
FreshCap (origin).singletonCaptureSet
528
524
@@ -572,7 +568,8 @@ object CaptureSet:
572
568
private var isComplete = true
573
569
574
570
def setMutable ()(using Context ): Unit =
575
- isComplete = false // delay computation of Mutability status
571
+ if ! elems.isEmpty then
572
+ isComplete = false // delay computation of Mutability status
576
573
577
574
override def mutability (using Context ): Mutability =
578
575
if ! isComplete then
@@ -589,12 +586,17 @@ object CaptureSet:
589
586
then i " under-approximating the result of mapping $ref to $mapped"
590
587
else " "
591
588
589
+ /* The same as {cap.rd} but generated implicitly for references of Capability subtypes.
590
+ */
591
+ case class CSImpliedByCapability () extends Const (SimpleIdentitySet (GlobalCap .readOnly))
592
+
592
593
/** A special capture set that gets added to the types of symbols that were not
593
594
* themselves capture checked, in order to admit arbitrary corresponding capture
594
595
* sets in subcapturing comparisons. Similar to platform types for explicit
595
596
* nulls, this provides more lenient checking against compilation units that
596
597
* were not yet compiled with capture checking on.
597
598
*/
599
+ @ sharable // sharable since the set is empty, so setMutable is a no-op
598
600
object Fluid extends Const (emptyRefs):
599
601
override def isAlwaysEmpty (using Context ) = false
600
602
override def addThisElem (elem : Capability )(using Context , VarState ) = true
0 commit comments