Skip to content

Commit 1a0be56

Browse files
committed
Add shortenCap config option to Printer
1 parent 6bf993c commit 1a0be56

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ class PlainPrinter(_ctx: Context) extends Printer {
4848
protected def homogenizedView: Boolean = ctx.settings.YtestPickler.value
4949
protected def debugPos: Boolean = ctx.settings.YdebugPos.value
5050

51+
/** If true, shorten local roots of current owner tp `cap`,
52+
* TODO: we should drop this switch once we implemented disambiguation of capture roots.
53+
*/
54+
private val shortenCap = true
55+
5156
def homogenize(tp: Type): Type =
5257
if (homogenizedView)
5358
tp match {
@@ -166,7 +171,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
166171
boxText ~ toTextLocal(parent) ~ "^"
167172
~ (refsText provided refsText != rootSetText)
168173

169-
final protected def rootSetText = Str("{cap}")
174+
final protected def rootSetText = Str("{cap}") // TODO Use disambiguation
170175

171176
def toText(tp: Type): Text = controlled {
172177
homogenize(tp) match {
@@ -238,6 +243,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
238243
tp.symbol.name == nme.LOCAL_CAPTURE_ROOT
239244
&& ctx.owner.levelOwner == tp.localRootOwner
240245
&& !printDebug
246+
&& shortenCap // !!!
241247
// local roots get printed as themselves under printDebug
242248
case _ =>
243249
false
@@ -374,7 +380,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
374380
tp match {
375381
case tp: TermRef =>
376382
if tp.symbol.name == nme.LOCAL_CAPTURE_ROOT then // TODO: Move to toTextCaptureRef
377-
if ctx.owner.levelOwner == tp.localRootOwner && !printDebug then
383+
if ctx.owner.levelOwner == tp.localRootOwner && !printDebug && shortenCap then
378384
Str("cap")
379385
else
380386
Str(s"cap[${tp.localRootOwner.name}]") ~

0 commit comments

Comments
 (0)