Skip to content

Commit 27126ae

Browse files
committed
Improve printing of capture sets before cc
Use the syntactic sugar instead of expanding with capsOf
1 parent 185f177 commit 27126ae

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ class PlainPrinter(_ctx: Context) extends Printer {
165165
private def toTextRetainedElem[T <: Untyped](ref: Tree[T]): Text = ref match
166166
case ref: RefTree[?] if ref.typeOpt.exists =>
167167
toTextCaptureRef(ref.typeOpt)
168+
case TypeApply(fn, arg :: Nil) if fn.symbol == defn.Caps_capsOf =>
169+
toTextRetainedElem(arg)
168170
case _ =>
169171
toText(ref)
170172

@@ -416,6 +418,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
416418
case tp: SingletonType => toTextRef(tp)
417419
case ReachCapability(tp1) => toTextRef(tp1) ~ "*"
418420
case MaybeCapability(tp1) => toTextRef(tp1) ~ "?"
421+
case tp: (TypeRef | TypeParamRef) => toText(tp) ~ "^"
419422
case _ => toText(tp)
420423

421424
protected def isOmittablePrefix(sym: Symbol): Boolean =

tests/pos/cc-poly-1.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import caps.{CapSet, Capability}
99

1010
def f[X^](x: D^{X^}): D^{X^} = x
1111
def g[X^](x: D^{X^}, y: D^{X^}): D^{X^} = x
12+
def h[X^](): D^{X^} = ???
1213

1314
def test(c1: C, c2: C) =
1415
val d: D^{c1, c2} = D()
@@ -19,5 +20,7 @@ import caps.{CapSet, Capability}
1920
val y = g(d1, d2)
2021
val _: D^{d1, d2} = y
2122
val _: D^{c1, c2} = y
23+
val z = h()
24+
2225

2326

0 commit comments

Comments
 (0)