@@ -1322,6 +1322,10 @@ class CheckCaptures extends Recheck, SymTransformer:
1322
1322
* where local capture roots are instantiated to root variables.
1323
1323
*/
1324
1324
override def checkConformsExpr (actual : Type , expected : Type , tree : Tree , addenda : Addenda )(using Context ): Type =
1325
+ testAdapted(actual, expected, tree, addenda)(err.typeMismatch)
1326
+
1327
+ inline def testAdapted (actual : Type , expected : Type , tree : Tree , addenda : Addenda )
1328
+ (fail : (Tree , Type , Addenda ) => Unit )(using Context ): Type =
1325
1329
var expected1 = alignDependentFunction(expected, actual.stripCapturing)
1326
1330
val actualBoxed = adapt(actual, expected1, tree)
1327
1331
// println(i"check conforms $actualBoxed <<< $expected1")
@@ -1332,18 +1336,16 @@ class CheckCaptures extends Recheck, SymTransformer:
1332
1336
TypeComparer .compareResult(isCompatible(actualBoxed, expected1)) match
1333
1337
case TypeComparer .CompareResult .Fail (notes) =>
1334
1338
capt.println(i " conforms failed for ${tree}: $actual vs $expected" )
1335
- err.typeMismatch(tree.withType(actualBoxed), expected1,
1336
- addApproxAddenda(
1337
- addenda ++ errorNotes(notes),
1338
- expected1))
1339
+ fail(tree.withType(actualBoxed), expected1,
1340
+ addApproxAddenda(addenda ++ errorNotes(notes), expected1))
1339
1341
actual
1340
1342
case /* OK*/ _ =>
1341
1343
if debugSuccesses then tree match
1342
- case Ident (_) =>
1343
- println(i " SUCCESS $tree for $actual <:< $expected: \n ${TypeComparer .explained(_.isSubType(actualBoxed, expected1))}" )
1344
- case _ =>
1344
+ case Ident (_) =>
1345
+ println(i " SUCCESS $tree for $actual <:< $expected: \n ${TypeComparer .explained(_.isSubType(actualBoxed, expected1))}" )
1346
+ case _ =>
1345
1347
actualBoxed
1346
- end checkConformsExpr
1348
+ end testAdapted
1347
1349
1348
1350
/** Turn `expected` into a dependent function when `actual` is dependent. */
1349
1351
private def alignDependentFunction (expected : Type , actual : Type )(using Context ): Type =
0 commit comments