@@ -1322,6 +1322,10 @@ class CheckCaptures extends Recheck, SymTransformer:
13221322 * where local capture roots are instantiated to root variables.
13231323 */
13241324 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 =
13251329 var expected1 = alignDependentFunction(expected, actual.stripCapturing)
13261330 val actualBoxed = adapt(actual, expected1, tree)
13271331 // println(i"check conforms $actualBoxed <<< $expected1")
@@ -1332,18 +1336,16 @@ class CheckCaptures extends Recheck, SymTransformer:
13321336 TypeComparer .compareResult(isCompatible(actualBoxed, expected1)) match
13331337 case TypeComparer .CompareResult .Fail (notes) =>
13341338 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))
13391341 actual
13401342 case /* OK*/ _ =>
13411343 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 _ =>
13451347 actualBoxed
1346- end checkConformsExpr
1348+ end testAdapted
13471349
13481350 /** Turn `expected` into a dependent function when `actual` is dependent. */
13491351 private def alignDependentFunction (expected : Type , actual : Type )(using Context ): Type =
0 commit comments