Skip to content

Commit 5aac2dc

Browse files
committed
Add -Yprint-debug to hide pretty-printing debug info by default
Currently, this flag only hides the "^" we display on inferred types, but in the future we can hide more stuff that shouldn't be seen by the user in error messages and in the IDE.
1 parent a041f07 commit 5aac2dc

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class ScalaSettings extends Settings.SettingGroup {
9292
val YnoDeepSubtypes = BooleanSetting("-Yno-deep-subtypes", "throw an exception on deep subtyping call stacks.")
9393
val YplainPrinter = BooleanSetting("-Yplain-printer", "Pretty-print using a plain printer.")
9494
val YprintSyms = BooleanSetting("-Yprint-syms", "when printing trees print info in symbols instead of corresponding info in trees.")
95+
val YprintDebug = BooleanSetting("-Yprint-debug", "when printing trees, print some extra information useful for debugging.")
9596
val YtestPickler = BooleanSetting("-Ytest-pickler", "self-test for pickling functionality; should be used with -Ystop-after:pickler")
9697
val YcheckReentrant = BooleanSetting("-Ycheck-reentrant", "check that compiled program does not contain vars that can be accessed from a global root.")
9798
val YkeepComments = BooleanSetting("-Ykeep-comments", "Keep comments when scanning source files.")

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,13 @@ class PlainPrinter(_ctx: Context) extends Printer {
190190
toTextLocal(tycon) ~ "[" ~ Text(args.map(argText), ", ") ~ "]"
191191
case tp: TypeVar =>
192192
if (tp.isInstantiated)
193-
toTextLocal(tp.instanceOpt) ~ "^" // debug for now, so that we can see where the TypeVars are.
193+
toTextLocal(tp.instanceOpt) ~ ("^" provided ctx.settings.YprintDebug.value)
194194
else {
195195
val constr = ctx.typerState.constraint
196196
val bounds =
197197
if (constr.contains(tp)) constr.fullBounds(tp.origin)(ctx.addMode(Mode.Printing))
198198
else TypeBounds.empty
199-
if (bounds.isAlias) toText(bounds.lo) ~ "^"
199+
if (bounds.isAlias) toText(bounds.lo) ~ ("^" provided ctx.settings.YprintDebug.value)
200200
else if (ctx.settings.YshowVarBounds.value) "(" ~ toText(tp.origin) ~ "?" ~ toText(bounds) ~ ")"
201201
else toText(tp.origin)
202202
}

0 commit comments

Comments
 (0)