@@ -618,11 +618,11 @@ class CheckCaptures extends Recheck, SymTransformer:
618
618
finally
619
619
curEnv = saved
620
620
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 "
624
624
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 ) {
626
626
val actualTp = actual match
627
627
case actual @ CapturingType (parent, cs) =>
628
628
(parent, cs, actual.isBoxed)
@@ -632,8 +632,11 @@ class CheckCaptures extends Recheck, SymTransformer:
632
632
val (parent1, cs1, isBoxed1) = adaptCapturingType(actualTp, expected, covariant)
633
633
634
634
CapturingType (parent1, cs1, isBoxed1)
635
+ }
635
636
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 ) =
637
640
val (parent, cs, actualIsBoxed) = actual
638
641
639
642
val needsAdaptation = actualIsBoxed != expected.isBoxedCapturing
@@ -660,13 +663,13 @@ class CheckCaptures extends Recheck, SymTransformer:
660
663
// We can't box/unbox the universal capability. Leave `actual` as it is
661
664
// so we get an error in checkConforms. This tends to give better error
662
665
// 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" )
664
667
actual
665
668
else
666
669
// Disallow future addition of `*` to `criticalSet`.
667
670
criticalSet.disallowRootCapability { () =>
668
671
report.error(
669
- em """ $actual cannot be box-converted to $expected
672
+ em """ $cs $parent cannot be box-converted to $expected
670
673
|since one of their capture sets contains the root capability `*` """ ,
671
674
pos)
672
675
}
0 commit comments