@@ -1218,6 +1218,19 @@ class CheckCaptures extends Recheck, SymTransformer:
12181218 |
12191219 |Note that ${msg.toString}"""
12201220
1221+ private def existentialSubsumesFailureAddenda (using Context ): Addenda =
1222+ ccState.existentialSubsumesFailure match
1223+ case Some ((ex @ Existential .Vble (binder), other)) =>
1224+ new Addenda :
1225+ override def toAdd (using Context ): List [String ] =
1226+ val ann = ex.annot.asInstanceOf [Fresh .Annot ]
1227+ i """
1228+ |
1229+ |Note that the existential capture root in ${ann.originalBinder.resType}
1230+ |cannot subsume the capability $other"""
1231+ :: Nil
1232+ case _ => NothingToAdd
1233+
12211234 /** Addendas for error messages that show where we have under-approximated by
12221235 * mapping a a capture ref in contravariant position to the empty set because
12231236 * the original result type of the map was not itself a capture ref.
@@ -1257,6 +1270,7 @@ class CheckCaptures extends Recheck, SymTransformer:
12571270 if actualBoxed eq actual then
12581271 // Only `addOuterRefs` when there is no box adaptation
12591272 expected1 = addOuterRefs(expected1, actual, tree.srcPos)
1273+ ccState.existentialSubsumesFailure = None
12601274 if isCompatible(actualBoxed, expected1) then
12611275 if debugSuccesses then tree match
12621276 case Ident (_) =>
@@ -1268,7 +1282,10 @@ class CheckCaptures extends Recheck, SymTransformer:
12681282 inContext(Fresh .printContext(actualBoxed, expected1)):
12691283 err.typeMismatch(tree.withType(actualBoxed), expected1,
12701284 addApproxAddenda(
1271- addenda ++ CaptureSet .levelErrors ++ boxErrorAddenda(boxErrors),
1285+ addenda
1286+ ++ CaptureSet .levelErrors
1287+ ++ boxErrorAddenda(boxErrors)
1288+ ++ existentialSubsumesFailureAddenda,
12721289 expected1))
12731290 actual
12741291 end checkConformsExpr
0 commit comments