@@ -618,11 +618,11 @@ class CheckCaptures extends Recheck, SymTransformer:
618618 finally
619619 curEnv = saved
620620
621- // def adaptInfo(actual: Type, expected: Type, covariant: Boolean): String =
622- // val (l, r) = if covariant then (actual, expected) else (expected, actual)
623- // i"adapting $l ~~> $r "
621+ def adaptInfo (actual : Type , expected : Type , covariant : Boolean ): String =
622+ val arrow = if covariant then " ~~> " else " <~~ "
623+ i " adapting $actual $arrow $expected "
624624
625- def adapt (actual : Type , expected : Type , covariant : Boolean ): Type =
625+ def adapt (actual : Type , expected : Type , covariant : Boolean ): Type = trace(adaptInfo(actual, expected, covariant), recheckr, show = true ) {
626626 val actualTp = actual match
627627 case actual @ CapturingType (parent, cs) =>
628628 (parent, cs, actual.isBoxed)
@@ -632,8 +632,11 @@ class CheckCaptures extends Recheck, SymTransformer:
632632 val (parent1, cs1, isBoxed1) = adaptCapturingType(actualTp, expected, covariant)
633633
634634 CapturingType (parent1, cs1, isBoxed1)
635+ }
635636
636- def adaptCapturingType (actual : (Type , CaptureSet , Boolean ), expected : Type , covariant : Boolean ): (Type , CaptureSet , Boolean ) =
637+ def adaptCapturingType (actual : (Type , CaptureSet , Boolean ),
638+ expected : Type ,
639+ covariant : Boolean ): (Type , CaptureSet , Boolean ) =
637640 val (parent, cs, actualIsBoxed) = actual
638641
639642 val needsAdaptation = actualIsBoxed != expected.isBoxedCapturing
@@ -660,13 +663,13 @@ class CheckCaptures extends Recheck, SymTransformer:
660663 // We can't box/unbox the universal capability. Leave `actual` as it is
661664 // so we get an error in checkConforms. This tends to give better error
662665 // messages than disallowing the root capability in `criticalSet`.
663- capt.println(i " cannot box/unbox $actual vs $expected" )
666+ capt.println(i " cannot box/unbox $cs $parent vs $expected" )
664667 actual
665668 else
666669 // Disallow future addition of `*` to `criticalSet`.
667670 criticalSet.disallowRootCapability { () =>
668671 report.error(
669- em """ $actual cannot be box-converted to $expected
672+ em """ $cs $parent cannot be box-converted to $expected
670673 |since one of their capture sets contains the root capability `*` """ ,
671674 pos)
672675 }
0 commit comments