diff --git a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala index aca5972d4516..46773f239c17 100644 --- a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala @@ -416,10 +416,10 @@ class PlainPrinter(_ctx: Context) extends Printer { homogenize(tp) match case tp: TermRef if tp.symbol == defn.captureRoot => Str("cap") case tp: SingletonType => toTextRef(tp) - case ReachCapability(tp1) => toTextRef(tp1) ~ "*" - case MaybeCapability(tp1) => toTextRef(tp1) ~ "?" case tp: (TypeRef | TypeParamRef) => toText(tp) ~ "^" - case _ => toText(tp) + case tp: AnnotatedType if tp.isReach => toTextCaptureRef(tp.stripReach) ~ "*" + case tp: AnnotatedType if tp.isMaybe => toTextCaptureRef(tp.stripMaybe) ~ "?" + case tp => toText(tp) protected def isOmittablePrefix(sym: Symbol): Boolean = defn.unqualifiedOwnerTypes.exists(_.symbol == sym) || isEmptyPrefix(sym) diff --git a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala index 9852dfc1170d..18a1647572ef 100644 --- a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -330,6 +330,8 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { "?" ~ (("(ignored: " ~ toText(ignored) ~ ")") provided printDebug) case tp @ PolyProto(targs, resType) => "[applied to [" ~ toTextGlobal(targs, ", ") ~ "] returning " ~ toText(resType) + case tp: AnnotatedType if tp.isReach || tp.isMaybe => + toTextCaptureRef(tp) case _ => super.toText(tp) } diff --git a/tests/neg-custom-args/captures/reaches2.check b/tests/neg-custom-args/captures/reaches2.check index f646a9736395..03860ee4a01b 100644 --- a/tests/neg-custom-args/captures/reaches2.check +++ b/tests/neg-custom-args/captures/reaches2.check @@ -1,10 +1,10 @@ -- Error: tests/neg-custom-args/captures/reaches2.scala:8:10 ----------------------------------------------------------- 8 | ps.map((x, y) => compose1(x, y)) // error // error | ^ - |reference (ps : List[(box A => A, box A => A)]) @reachCapability is not included in the allowed capture set {} + |reference ps* is not included in the allowed capture set {} |of an enclosing function literal with expected type ((box A ->{ps*} A, box A ->{ps*} A)) -> box (x$0: A^?) ->? (ex$15: caps.Exists) -> A^? -- Error: tests/neg-custom-args/captures/reaches2.scala:8:13 ----------------------------------------------------------- 8 | ps.map((x, y) => compose1(x, y)) // error // error | ^ - |reference (ps : List[(box A => A, box A => A)]) @reachCapability is not included in the allowed capture set {} + |reference ps* is not included in the allowed capture set {} |of an enclosing function literal with expected type ((box A ->{ps*} A, box A ->{ps*} A)) -> box (x$0: A^?) ->? (ex$15: caps.Exists) -> A^?