Skip to content

Commit 133ab74

Browse files
committed
Better printing of <skolem> prefixes in FreshCaps
- Print <skolem> and this as prefix only under -Ycc-verbose - Compose a "in new instance of class C" owner for skolem prefixes
1 parent 6689785 commit 133ab74

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

compiler/src/dotty/tools/dotc/cc/Capability.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ object Capabilities:
205205
hiddenSet.adoptClassifier(cls)
206206
if freeze then isClassified = true
207207

208+
def ccOwnerStr(using Context): String =
209+
val owner = ccOwner
210+
if owner.name == nme.SKOLEM then i"a new instance of ${hiddenSet.owner}"
211+
else owner.show
212+
208213
def descr(using Context) =
209214
val originStr = origin match
210215
case Origin.InDecl(sym) if sym.exists =>

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,11 +492,13 @@ class PlainPrinter(_ctx: Context) extends Printer {
492492
if c.hiddenSet.classifier == defn.AnyClass then ""
493493
else s" classified as ${c.hiddenSet.classifier.name.show}"
494494
def prefixTxt: Text = c.prefix match
495-
case NoPrefix | _: ThisType => ""
495+
case NoPrefix => ""
496+
case _: ThisType if !ccVerbose => ""
497+
case pre: TermRef if !ccVerbose && pre.name == nme.SKOLEM => ""
496498
case pre: SingletonType => toTextRef(pre) ~ "."
497499
case pre => toText(pre) ~ "."
498500
def core: Text =
499-
if ccVerbose then s"<fresh$idStr in ${c.ccOwner} hiding " ~ toTextCaptureSet(c.hiddenSet) ~ classified ~ ">"
501+
if ccVerbose then s"<fresh$idStr in ${c.ccOwnerStr} hiding " ~ toTextCaptureSet(c.hiddenSet) ~ classified ~ ">"
500502
else "cap"
501503
prefixTxt ~ core
502504
case tp: TypeProxy =>

0 commit comments

Comments
 (0)