@@ -1300,20 +1300,6 @@ object CaptureSet:
13001300 /** A TypeMap that is the identity on capabilities */
13011301 trait IdentityCaptRefMap extends TypeMap
13021302
1303- /** A value of this class is produced and added as a note to ccState
1304- * when a subsumes check decides that an existential variable `ex` cannot be
1305- * instantiated to the other capability `other`.
1306- */
1307- case class ExistentialSubsumesFailure (val ex : ResultCap , val other : Capability ) extends Note :
1308- def render (using Context ): String =
1309- def reason =
1310- if other.isTerminalCapability then " "
1311- else " since that capability is not a `Sharable` capability"
1312- i """
1313- |
1314- |Note that the existential capture root in ${ex.originalBinder.resType}
1315- |cannot subsume the capability $other$reason. """
1316-
13171303 /** Failure indicating that `elem` cannot be included in `cs` */
13181304 case class IncludeFailure (cs : CaptureSet , elem : Capability , levelError : Boolean = false ) extends Note , Showable :
13191305 private var myTrace : List [CaptureSet ] = cs :: Nil
@@ -1342,44 +1328,47 @@ object CaptureSet:
13421328 |
13431329 | """
13441330
1345- def render (using Context ): String =
1346- def why =
1347- val reasons = cs.elems.toList.collect:
1348- case c : FreshCap if ! c.acceptsLevelOf(elem) =>
1349- i " $elem${elem.levelOwner.qualString(" in" )} is not visible from $c${c.ccOwner.qualString(" in" )}"
1350- case c : FreshCap if ! elem.tryClassifyAs(c.hiddenSet.classifier) =>
1351- i " $c is classified as ${c.hiddenSet.classifier} but $elem is not "
1352- if reasons.isEmpty then " "
1353- else reasons.mkString(" \n because " , " \n and " , " " )
1354- cs match
1355- case cs : Var =>
1356- def ownerStr =
1357- if ! cs.description.isEmpty then " " else cs.owner.qualString(" which is owned by" )
1358- if ! cs.levelOK(elem) then
1359- val outlivesStr = elem match
1360- case ref : TermRef => i " ${ref.symbol.maybeOwner.qualString(" defined in" )} outlives its scope: \n "
1361- case _ => " outlives its scope: "
1362- leading :
1363- i """ Capability ${elem.showAsCapability}${outlivesStr}it leaks into outer capture set $cs$ownerStr"""
1364- else if ! elem.tryClassifyAs(cs.classifier) then
1365- trailing :
1366- i """ capability ${elem.showAsCapability} is not classified as ${cs.classifier}, therefore it
1367- |cannot be included in capture set $cs of ${cs.classifier.name} elements """
1368- else if cs.isBadRoot(elem) then
1369- elem match
1370- case elem : FreshCap =>
1371- leading :
1372- i """ Local capability ${elem.showAsCapability} created in ${elem.ccOwner} outlives its scope:
1373- |It leaks into outer capture set $cs$ownerStr"""
1374- case _ =>
1375- trailing :
1376- i " universal capability ${elem.showAsCapability} cannot be included in capture set $cs"
1377- else
1378- trailing :
1379- i " capability ${elem.showAsCapability} cannot be included in capture set $cs"
1380- case _ =>
1331+ def render (using Context ): String = cs match
1332+ case cs : Var =>
1333+ def ownerStr =
1334+ if ! cs.description.isEmpty then " " else cs.owner.qualString(" which is owned by" )
1335+ if ! cs.levelOK(elem) then
1336+ val outlivesStr = elem match
1337+ case ref : TermRef => i " ${ref.symbol.maybeOwner.qualString(" defined in" )} outlives its scope: \n "
1338+ case _ => " outlives its scope: "
1339+ leading :
1340+ i """ Capability ${elem.showAsCapability}${outlivesStr}it leaks into outer capture set $cs$ownerStr"""
1341+ else if ! elem.tryClassifyAs(cs.classifier) then
1342+ trailing :
1343+ i """ capability ${elem.showAsCapability} is not classified as ${cs.classifier}, therefore it
1344+ |cannot be included in capture set $cs of ${cs.classifier.name} elements """
1345+ else if cs.isBadRoot(elem) then
1346+ elem match
1347+ case elem : FreshCap =>
1348+ leading :
1349+ i """ Local capability ${elem.showAsCapability} created in ${elem.ccOwner} outlives its scope:
1350+ |It leaks into outer capture set $cs$ownerStr"""
1351+ case _ =>
1352+ trailing :
1353+ i " universal capability ${elem.showAsCapability} cannot be included in capture set $cs"
1354+ else
13811355 trailing :
1382- i " capability ${elem.showAsCapability} is not included in capture set $cs$why"
1356+ i " capability ${elem.showAsCapability} cannot be included in capture set $cs"
1357+ case _ =>
1358+ def why =
1359+ val reasons = cs.elems.toList.collect:
1360+ case c : FreshCap if ! c.acceptsLevelOf(elem) =>
1361+ i " $elem${elem.levelOwner.qualString(" in" )} is not visible from $c${c.ccOwner.qualString(" in" )}"
1362+ case c : FreshCap if ! elem.tryClassifyAs(c.hiddenSet.classifier) =>
1363+ i " $c is classified as ${c.hiddenSet.classifier} but ${elem.showAsCapability} is not "
1364+ case c : ResultCap if ! c.subsumes(elem) =>
1365+ val toAdd = if elem.isTerminalCapability then " " else " since that capability is not a SharedCapability"
1366+ i " $c, which is existentially bound in ${c.originalBinder.resType}, cannot subsume ${elem.showAsCapability}$toAdd"
1367+ if reasons.isEmpty then " "
1368+ else reasons.mkString(" \n because " , " \n and " , " " )
1369+
1370+ trailing :
1371+ i " capability ${elem.showAsCapability} is not included in capture set $cs$why"
13831372
13841373 override def toText (printer : Printer ): Text =
13851374 inContext(printer.printerContext):
0 commit comments