@@ -16,6 +16,7 @@ import util.{SimpleIdentitySet, Property}
1616import util .common .alwaysTrue
1717import scala .collection .mutable
1818import config .Config .ccAllowUnsoundMaps
19+ import language .experimental .pureFunctions
1920
2021/** A class for capture sets. Capture sets can be constants or variables.
2122 * Capture sets support inclusion constraints <:< where <:< is subcapturing.
@@ -37,7 +38,7 @@ import config.Config.ccAllowUnsoundMaps
3738 * if the mapped function is either a bijection or if it is idempotent
3839 * on capture references (c.f. doc comment on `map` below).
3940 */
40- sealed abstract class CaptureSet extends Showable :
41+ sealed abstract class CaptureSet extends Showable , caps. Pure :
4142 import CaptureSet .*
4243
4344 /** The elements of this capture set. For capture variables,
@@ -222,7 +223,7 @@ sealed abstract class CaptureSet extends Showable:
222223 /** The largest subset (via <:<) of this capture set that only contains elements
223224 * for which `p` is true.
224225 */
225- def filter (p : CaptureRef = > Boolean )(using Context ): CaptureSet =
226+ def filter (p : CaptureRef - > Boolean )(using Context ): CaptureSet =
226227 if this .isConst then
227228 val elems1 = elems.filter(p)
228229 if elems1 == elems then this
@@ -377,8 +378,10 @@ object CaptureSet:
377378 def isConst = isSolved
378379 def isAlwaysEmpty = false
379380
380- /** A handler to be invoked if the root reference `*` is added to this set */
381- var rootAddedHandler : () => Context ?=> Unit = () => ()
381+ /** A handler to be invoked if the root reference `*` is added to this set
382+ * The handler is pure in the sense that it will only output diagnostics.
383+ */
384+ var rootAddedHandler : () -> Context ?-> Unit = () => ()
382385
383386 var description : String = " "
384387
@@ -426,7 +429,7 @@ object CaptureSet:
426429 else
427430 CompareResult .fail(this )
428431
429- override def disallowRootCapability (handler : () = > Context ?= > Unit )(using Context ): this .type =
432+ override def disallowRootCapability (handler : () - > Context ?- > Unit )(using Context ): this .type =
430433 rootAddedHandler = handler
431434 super .disallowRootCapability(handler)
432435
@@ -618,7 +621,7 @@ object CaptureSet:
618621
619622 /** A variable with elements given at any time as { x <- source.elems | p(x) } */
620623 class Filtered private [CaptureSet ]
621- (val source : Var , p : CaptureRef = > Boolean )(using @ constructorOnly ctx : Context )
624+ (val source : Var , p : CaptureRef - > Boolean )(using @ constructorOnly ctx : Context )
622625 extends DerivedVar (source.elems.filter(p)):
623626
624627 override def addNewElems (newElems : Refs , origin : CaptureSet )(using Context , VarState ): CompareResult =
0 commit comments