Skip to content

Commit d06a5e6

Browse files
committed
Fix printing of reach capabilities
1 parent 7e7b3f9 commit d06a5e6

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,10 +416,10 @@ class PlainPrinter(_ctx: Context) extends Printer {
416416
homogenize(tp) match
417417
case tp: TermRef if tp.symbol == defn.captureRoot => Str("cap")
418418
case tp: SingletonType => toTextRef(tp)
419-
case ReachCapability(tp1) => toTextRef(tp1) ~ "*"
420-
case MaybeCapability(tp1) => toTextRef(tp1) ~ "?"
421419
case tp: (TypeRef | TypeParamRef) => toText(tp) ~ "^"
422-
case _ => toText(tp)
420+
case tp: AnnotatedType if tp.isReach => toTextCaptureRef(tp.stripReach) ~ "*"
421+
case tp: AnnotatedType if tp.isMaybe => toTextCaptureRef(tp.stripMaybe) ~ "?"
422+
case tp => toText(tp)
423423

424424
protected def isOmittablePrefix(sym: Symbol): Boolean =
425425
defn.unqualifiedOwnerTypes.exists(_.symbol == sym) || isEmptyPrefix(sym)

compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
330330
"?" ~ (("(ignored: " ~ toText(ignored) ~ ")") provided printDebug)
331331
case tp @ PolyProto(targs, resType) =>
332332
"[applied to [" ~ toTextGlobal(targs, ", ") ~ "] returning " ~ toText(resType)
333+
case tp: AnnotatedType if tp.isReach || tp.isMaybe =>
334+
toTextCaptureRef(tp)
333335
case _ =>
334336
super.toText(tp)
335337
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
-- Error: tests/neg-custom-args/captures/reaches2.scala:8:10 -----------------------------------------------------------
22
8 | ps.map((x, y) => compose1(x, y)) // error // error
33
| ^
4-
|reference (ps : List[(box A => A, box A => A)]) @reachCapability is not included in the allowed capture set {}
4+
|reference ps* is not included in the allowed capture set {}
55
|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^?
66
-- Error: tests/neg-custom-args/captures/reaches2.scala:8:13 -----------------------------------------------------------
77
8 | ps.map((x, y) => compose1(x, y)) // error // error
88
| ^
9-
|reference (ps : List[(box A => A, box A => A)]) @reachCapability is not included in the allowed capture set {}
9+
|reference ps* is not included in the allowed capture set {}
1010
|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^?

0 commit comments

Comments
 (0)