Skip to content

Commit ad7333e

Browse files
committed
Print bounds of TypeVars only when option is enabled.
1 parent c864e11 commit ad7333e

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ class ScalaSettings extends Settings.SettingGroup {
173173
val Ypatmatdebug = BooleanSetting("-Ypatmat-debug", "Trace pattern matching translation.")
174174
val Yexplainlowlevel = BooleanSetting("-Yexplain-lowlevel", "When explaining type errors, show types at a lower level.")
175175
val YnoDoubleBindings = BooleanSetting("-Yno-double-bindings", "Assert no namedtype is bound twice (should be enabled only if program is error-free).")
176+
val YshowVarBounds = BooleanSetting("-YshowVarBounds", "Print type variables with their bounds")
176177

177178
val optimise = BooleanSetting("-optimise", "Generates faster bytecode by applying optimisations to the program") withAbbreviation "-optimize"
178179

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ class PlainPrinter(_ctx: Context) extends Printer {
170170
val bounds =
171171
if (constr.contains(tp)) constr.fullBounds(tp.origin)(ctx.addMode(Mode.Printing))
172172
else TypeBounds.empty
173-
"(" ~ toText(tp.origin) ~ "?" ~ toText(bounds) ~ ")"
173+
if (ctx.settings.YshowVarBounds.value) "(" ~ toText(tp.origin) ~ "?" ~ toText(bounds) ~ ")"
174+
else toText(tp.origin)
174175
}
175176
case tp: LazyRef =>
176177
"LazyRef(" ~ toTextGlobal(tp.ref) ~ ")"

0 commit comments

Comments
 (0)