@@ -1317,6 +1317,18 @@ object CaptureSet:
13171317 case _ =>
13181318 false
13191319
1320+ /** An include failure F1 covers another include failure F2 unless F2
1321+ * strictly subsumes F1, which means they describe the same capture sets
1322+ * and the element in F2 is more specific than the element in F1.
1323+ */
1324+ override def covers (other : Note )(using Context ) = other match
1325+ case other @ IncludeFailure (cs1, elem1, _) =>
1326+ val strictlySubsumes =
1327+ cs.elems == cs1.elems
1328+ && elem1.singletonCaptureSet.mightSubcapture(elem.singletonCaptureSet)
1329+ ! strictlySubsumes
1330+ case _ => false
1331+
13201332 def trailing (msg : String )(using Context ): String =
13211333 i """
13221334 |
@@ -1387,13 +1399,19 @@ object CaptureSet:
13871399 * @param hi the upper type of the orginal type comparison, or NoType if not known
13881400 */
13891401 case class MutAdaptFailure (cs : CaptureSet , lo : Type = NoType , hi : Type = NoType ) extends Note :
1402+
13901403 def render (using Context ): String =
13911404 def ofType (tp : Type ) = if tp.exists then i " of the mutable type $tp" else " of a mutable type"
13921405 i """
13931406 |
13941407 |Note that $cs is an exclusive capture set ${ofType(hi)},
13951408 |it cannot subsume a read-only capture set ${ofType(lo)}. """
13961409
1410+ // Show only one failure of this kind
1411+ override def covers (other : Note )(using Context ) =
1412+ other.isInstanceOf [MutAdaptFailure ]
1413+ end MutAdaptFailure
1414+
13971415 /** A VarState serves as a snapshot mechanism that can undo
13981416 * additions of elements or super sets if an operation fails
13991417 */
0 commit comments