Skip to content

Commit 69be52f

Browse files
committed
Address review: respect -Ydebug-print in ReplPrinter
1 parent ecdf175 commit 69be52f

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,27 @@ import dotty.tools.dotc.printing.Texts._
1313

1414
class ReplPrinter(_ctx: Context) extends DecompilerPrinter(_ctx) {
1515

16+
val debugPrint = _ctx.settings.YprintDebug.value
17+
1618
override def nameString(name: Name): String =
1719
if (name.isReplAssignName) name.decode.toString.takeWhile(_ != '$')
1820
else super.nameString(name)
1921

2022
override protected def exprToText(tp: ExprType): Text =
21-
": " ~ toText(tp.resType)
23+
if (debugPrint) super.exprToText(tp)
24+
else ": " ~ toText(tp.resType)
2225

2326
override def toText(sym: Symbol): Text =
2427
if (sym.name.isReplAssignName) nameString(sym.name)
28+
else if (debugPrint) super.toText(sym)
2529
else keyString(sym) ~~ nameString(sym.name.stripModuleClassSuffix)
2630

2731
override def toText(const: Constant): Text =
28-
if (const.tag == Constants.StringTag) Str('"' + const.value.toString + '"')
32+
if (debugPrint) super.toText(const)
33+
else if (const.tag == Constants.StringTag) Str('"' + const.value.toString + '"')
2934
else Str(const.value.toString)
3035

31-
override def dclText(sym: Symbol): Text = {
36+
override def dclText(sym: Symbol): Text = if (debugPrint) super.dclText(sym) else {
3237
("lazy": Text).provided(sym.is(Lazy)) ~~
3338
toText(sym) ~ {
3439
if (sym.is(Method)) toText(sym.info)
@@ -38,10 +43,14 @@ class ReplPrinter(_ctx: Context) extends DecompilerPrinter(_ctx) {
3843
}
3944
}
4045

41-
override def toTextSingleton(tp: SingletonType): Text = tp match {
42-
case ConstantType(const) => toText(const)
43-
case _ => toTextRef(tp) ~ ".type"
44-
}
46+
override def toTextSingleton(tp: SingletonType): Text =
47+
if (debugPrint)
48+
super.toTextSingleton(tp)
49+
else
50+
tp match {
51+
case ConstantType(const) => toText(const)
52+
case _ => toTextRef(tp) ~ ".type"
53+
}
4554

4655
// We don't want the colors coming from RefinedPrinter as the REPL uses its
4756
// own syntax coloring mechanism.

0 commit comments

Comments
 (0)