@@ -7,28 +7,33 @@ import dotty.tools.dotc.core.Flags._
77import dotty .tools .dotc .core .NameOps ._
88import dotty .tools .dotc .core .Names .Name
99import dotty .tools .dotc .core .Symbols ._
10- import dotty .tools .dotc .core .Types .ExprType
10+ import dotty .tools .dotc .core .Types ._
1111import dotty .tools .dotc .printing .Texts ._
1212
1313
1414class 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,6 +43,15 @@ class ReplPrinter(_ctx: Context) extends DecompilerPrinter(_ctx) {
3843 }
3944 }
4045
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+ }
54+
4155 // We don't want the colors coming from RefinedPrinter as the REPL uses its
4256 // own syntax coloring mechanism.
4357 override def coloredStr (text : String , color : String ): String = text
0 commit comments