@@ -18,7 +18,7 @@ import util.{SimpleIdentitySet, EqHashMap, EqHashSet, SrcPos, Property}
18
18
import transform .{Recheck , PreRecheck , CapturedVars }
19
19
import Recheck .*
20
20
import scala .collection .mutable
21
- import CaptureSet .{withCaptureSetsExplained , IdempotentCaptRefMap , CompareResult , ExistentialSubsumesFailure }
21
+ import CaptureSet .{withCaptureSetsExplained , IdempotentCaptRefMap , CompareResult , CompareFailure , ExistentialSubsumesFailure }
22
22
import CCState .*
23
23
import StdNames .nme
24
24
import NameKinds .{DefaultGetterName , WildcardParamName , UniqueNameKind }
@@ -352,13 +352,15 @@ class CheckCaptures extends Recheck, SymTransformer:
352
352
353
353
/** If `res` is not CompareResult.OK, report an error */
354
354
def checkOK (res : CompareResult , prefix : => String , added : CaptureRef | CaptureSet , pos : SrcPos , provenance : => String = " " )(using Context ): Unit =
355
- if ! res.isOK then
356
- inContext(root.printContext(added, res.blocking)):
357
- def toAdd : String = errorNotes(res.errorNotes).toAdd.mkString
358
- def descr : String =
359
- val d = res.blocking.description
360
- if d.isEmpty then provenance else " "
361
- report.error(em " $prefix included in the allowed capture set ${res.blocking}$descr$toAdd" , pos)
355
+ res match
356
+ case res : CompareFailure =>
357
+ inContext(root.printContext(added, res.blocking)):
358
+ def toAdd : String = errorNotes(res.errorNotes).toAdd.mkString
359
+ def descr : String =
360
+ val d = res.blocking.description
361
+ if d.isEmpty then provenance else " "
362
+ report.error(em " $prefix included in the allowed capture set ${res.blocking}$descr$toAdd" , pos)
363
+ case _ =>
362
364
363
365
/** Check subcapturing `{elem} <: cs`, report error on failure */
364
366
def checkElem (elem : CaptureRef , cs : CaptureSet , pos : SrcPos , provenance : => String = " " )(using Context ) =
@@ -1272,21 +1274,21 @@ class CheckCaptures extends Recheck, SymTransformer:
1272
1274
if actualBoxed eq actual then
1273
1275
// Only `addOuterRefs` when there is no box adaptation
1274
1276
expected1 = addOuterRefs(expected1, actual, tree.srcPos)
1275
- val result = ccState.testOK(isCompatible(actualBoxed, expected1))
1276
- if result.isOK then
1277
- if debugSuccesses then tree match
1278
- case Ident (_) =>
1279
- println(i " SUCCESS $tree for $actual <:< $expected: \n ${TypeComparer .explained(_.isSubType(actualBoxed, expected1))}" )
1280
- case _ =>
1281
- actualBoxed
1282
- else
1283
- capt.println(i " conforms failed for ${tree}: $actual vs $expected" )
1284
- inContext(root.printContext(actualBoxed, expected1)):
1285
- err.typeMismatch(tree.withType(actualBoxed), expected1,
1286
- addApproxAddenda(
1287
- addenda ++ errorNotes(result .errorNotes),
1288
- expected1))
1289
- actual
1277
+ ccState.testOK(isCompatible(actualBoxed, expected1)) match
1278
+ case CompareResult . OK =>
1279
+ if debugSuccesses then tree match
1280
+ case Ident (_) =>
1281
+ println(i " SUCCESS $tree for $actual <:< $expected: \n ${TypeComparer .explained(_.isSubType(actualBoxed, expected1))}" )
1282
+ case _ =>
1283
+ actualBoxed
1284
+ case fail : CompareFailure =>
1285
+ capt.println(i " conforms failed for ${tree}: $actual vs $expected" )
1286
+ inContext(root.printContext(actualBoxed, expected1)):
1287
+ err.typeMismatch(tree.withType(actualBoxed), expected1,
1288
+ addApproxAddenda(
1289
+ addenda ++ errorNotes(fail .errorNotes),
1290
+ expected1))
1291
+ actual
1290
1292
end checkConformsExpr
1291
1293
1292
1294
/** Turn `expected` into a dependent function when `actual` is dependent. */
0 commit comments