@@ -394,7 +394,13 @@ sealed abstract class CaptureSet extends Showable:
394394 if mappedElems == elems then this
395395 else Const (mappedElems)
396396 else if ccState.mapFutureElems then
397- def unfused = BiMapped (asVar, tm, mappedElems)
397+ def unfused =
398+ if debugVars then
399+ try BiMapped (asVar, tm, mappedElems)
400+ catch case ex : AssertionError =>
401+ println(i " error while mapping $this" )
402+ throw ex
403+ else BiMapped (asVar, tm, mappedElems)
398404 this match
399405 case self : BiMapped => self.bimap.fuse(tm) match
400406 case Some (fused : BiTypeMap ) => BiMapped (self.source, fused, mappedElems)
@@ -652,8 +658,12 @@ object CaptureSet:
652658 override def toString = " <fluid>"
653659 end Fluid
654660
661+ /** If true emit info when var with id debugTarget is created or gets a new element */
662+ inline val debugVars = false
663+ inline val debugTarget = 22
664+
655665 /** The subclass of captureset variables with given initial elements */
656- class Var (initialOwner : Symbol = NoSymbol , initialElems : Refs = emptyRefs, val level : Level = undefinedLevel, underBox : Boolean = false )(using @ constructorOnly ictx : Context ) extends CaptureSet :
666+ class Var (initialOwner : Symbol = NoSymbol , initialElems : Refs = emptyRefs, val level : Level = undefinedLevel, underBox : Boolean = false )(using /* @constructorOnly*/ ictx : Context ) extends CaptureSet :
657667
658668 override def owner = initialOwner
659669
@@ -678,8 +688,14 @@ object CaptureSet:
678688 /** The elements currently known to be in the set */
679689 protected var myElems : Refs = initialElems
680690
691+ if debugVars && id == debugTarget then
692+ println(i " ###INIT ELEMS of $id to $initialElems" )
693+
681694 def elems : Refs = myElems
682- def elems_= (refs : Refs ): Unit = myElems = refs
695+ def elems_= (refs : Refs ): Unit =
696+ if debugVars && id == debugTarget then
697+ println(i " ###SET ELEMS of $id to $refs" )
698+ myElems = refs
683699
684700 /** The sets currently known to be dependent sets (i.e. new additions to this set
685701 * are propagated to these dependent sets.)
@@ -762,6 +778,8 @@ object CaptureSet:
762778
763779 protected def includeElem (elem : Capability )(using Context ): Unit =
764780 if ! elems.contains(elem) then
781+ if debugVars && id == debugTarget then
782+ println(i " ###INCLUDE $elem in $this" )
765783 elems += elem
766784 TypeComparer .logUndoAction: () =>
767785 elems -= elem
0 commit comments