@@ -76,11 +76,6 @@ sealed abstract class CaptureSet extends Showable:
76
76
/** Is this set provisionally solved, so that another cc run might unfreeze it? */
77
77
def isProvisionallySolved (using Context ): Boolean
78
78
79
- /** An optional level limit, or undefinedLevel if none exists. All elements of the set
80
- * must be at levels equal or smaller than the level of the set, if it is defined.
81
- */
82
- def level : Level
83
-
84
79
/** An optional owner, or NoSymbol if none exists. Used for diagnstics
85
80
*/
86
81
def owner : Symbol
@@ -394,7 +389,13 @@ sealed abstract class CaptureSet extends Showable:
394
389
if mappedElems == elems then this
395
390
else Const (mappedElems)
396
391
else if ccState.mapFutureElems then
397
- def unfused = BiMapped (asVar, tm, mappedElems)
392
+ def unfused =
393
+ if debugVars then
394
+ try BiMapped (asVar, tm, mappedElems)
395
+ catch case ex : AssertionError =>
396
+ println(i " error while mapping $this" )
397
+ throw ex
398
+ else BiMapped (asVar, tm, mappedElems)
398
399
this match
399
400
case self : BiMapped => self.bimap.fuse(tm) match
400
401
case Some (fused : BiTypeMap ) => BiMapped (self.source, fused, mappedElems)
@@ -601,8 +602,6 @@ object CaptureSet:
601
602
602
603
def withDescription (description : String ): Const = Const (elems, description)
603
604
604
- def level = undefinedLevel
605
-
606
605
def owner = NoSymbol
607
606
608
607
def dropEmpties ()(using Context ) = this
@@ -652,8 +651,12 @@ object CaptureSet:
652
651
override def toString = " <fluid>"
653
652
end Fluid
654
653
654
+ /** If true emit info when var with id debugTarget is created or gets a new element */
655
+ inline val debugVars = false
656
+ inline val debugTarget = 1745
657
+
655
658
/** 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 :
659
+ class Var (initialOwner : Symbol = NoSymbol , initialElems : Refs = emptyRefs, underBox : Boolean = false )(using /* @constructorOnly*/ ictx : Context ) extends CaptureSet :
657
660
658
661
override def owner = initialOwner
659
662
@@ -678,8 +681,15 @@ object CaptureSet:
678
681
/** The elements currently known to be in the set */
679
682
protected var myElems : Refs = initialElems
680
683
684
+ if debugVars && id == debugTarget then
685
+ println(i " ###INIT ELEMS of $id to $initialElems" )
686
+ assert(false )
687
+
681
688
def elems : Refs = myElems
682
- def elems_= (refs : Refs ): Unit = myElems = refs
689
+ def elems_= (refs : Refs ): Unit =
690
+ if debugVars && id == debugTarget then
691
+ println(i " ###SET ELEMS of $id to $refs" )
692
+ myElems = refs
683
693
684
694
/** The sets currently known to be dependent sets (i.e. new additions to this set
685
695
* are propagated to these dependent sets.)
@@ -762,6 +772,8 @@ object CaptureSet:
762
772
763
773
protected def includeElem (elem : Capability )(using Context ): Unit =
764
774
if ! elems.contains(elem) then
775
+ if debugVars && id == debugTarget then
776
+ println(i " ###INCLUDE $elem in $this" )
765
777
elems += elem
766
778
TypeComparer .logUndoAction: () =>
767
779
elems -= elem
@@ -815,37 +827,17 @@ object CaptureSet:
815
827
find(false , binder)
816
828
817
829
def levelOK (elem : Capability )(using Context ): Boolean = elem match
818
- case _ : FreshCap =>
819
- ! level.isDefined
820
- || ccState.symLevel(elem.ccOwner) <= level
821
- || {
822
- capt.println(i " LEVEL ERROR $elem cannot be included in $this of $owner" )
823
- false
824
- }
825
830
case elem @ ResultCap (binder) =>
826
831
rootLimit == null && (this .isInstanceOf [BiMapped ] || isPartOf(binder.resType))
827
832
case GlobalCap =>
828
833
rootLimit == null
829
- case elem : TermRef if level.isDefined =>
830
- elem.prefix match
831
- case prefix : Capability =>
832
- levelOK(prefix)
833
- case _ =>
834
- ccState.symLevel(elem.symbol) <= level
835
- case elem : ThisType if level.isDefined =>
836
- ccState.symLevel(elem.cls).nextInner <= level
837
- case elem : ParamRef if ! this .isInstanceOf [BiMapped ] =>
838
- isPartOf(elem.binder.resType)
839
- || {
840
- capt.println(
841
- i """ LEVEL ERROR $elem for $this
842
- |elem binder = ${elem.binder}""" )
843
- false
844
- }
845
- case elem : DerivedCapability =>
846
- levelOK(elem.underlying)
834
+ case elem : ParamRef =>
835
+ this .isInstanceOf [BiMapped ] || isPartOf(elem.binder.resType)
847
836
case _ =>
848
- true
837
+ if owner.exists then
838
+ val elemVis = elem.visibility
839
+ ! elemVis.isProperlyContainedIn(owner)
840
+ else true
849
841
850
842
def addDependent (cs : CaptureSet )(using Context , VarState ): Boolean =
851
843
(cs eq this )
@@ -926,15 +918,9 @@ object CaptureSet:
926
918
*/
927
919
override def optionalInfo (using Context ): String =
928
920
for vars <- ctx.property(ShownVars ) do vars += this
929
- val debugInfo =
930
- if ! ctx.settings.YccDebug .value then " "
931
- else if isConst then ids ++ " (solved)"
932
- else ids
933
- val limitInfo =
934
- if ctx.settings.YprintLevel .value && level.isDefined
935
- then i " <at level ${level.toString}> "
936
- else " "
937
- debugInfo ++ limitInfo
921
+ if ! ctx.settings.YccDebug .value then " "
922
+ else if isConst then ids ++ " (solved)"
923
+ else ids
938
924
939
925
/** Used for diagnostics and debugging: A string that traces the creation
940
926
* history of a variable by following source links. Each variable on the
@@ -1206,6 +1192,7 @@ object CaptureSet:
1206
1192
if alias ne this then alias.add(elem)
1207
1193
else
1208
1194
def addToElems () =
1195
+ assert(! isConst)
1209
1196
includeElem(elem)
1210
1197
deps.foreach: dep =>
1211
1198
assert(dep != this )
@@ -1335,7 +1322,7 @@ object CaptureSet:
1335
1322
override def toText (printer : Printer ): Text =
1336
1323
inContext(printer.printerContext):
1337
1324
if levelError then
1338
- i " ( $elem at wrong level for $cs at level ${cs.level.toString }) "
1325
+ i " ( $elem at wrong level for $cs in ${cs.owner.showLocated }) "
1339
1326
else
1340
1327
if ctx.settings.YccDebug .value
1341
1328
then i " $elem cannot be included in $trace"
@@ -1378,8 +1365,10 @@ object CaptureSet:
1378
1365
* but the special state VarState.Separate overrides this.
1379
1366
*/
1380
1367
def addHidden (hidden : HiddenSet , elem : Capability )(using Context ): Boolean =
1381
- hidden.add(elem)(using ctx, this )
1382
- true
1368
+ if hidden.isConst then false
1369
+ else
1370
+ hidden.add(elem)(using ctx, this )
1371
+ true
1383
1372
1384
1373
/** If root1 and root2 belong to the same binder but have different originalBinders
1385
1374
* it means that one of the roots was mapped to the binder of the other by a
0 commit comments