Skip to content

Commit f636b06

Browse files
committed
Move some logic from UserFacingPrinter to RefinedPrinter
1 parent 3fa6f6f commit f636b06

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,23 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
703703
super.toText(sym)
704704
}
705705

706+
override def toText(const: Constant): Text =
707+
if (!YprintRepl) super.toText(const)
708+
else if (const.tag == StringTag) Str('"' + const.value.toString + '"')
709+
else Str(const.value.toString)
710+
711+
override def dclText(sym: Symbol): Text = {
712+
if (!YprintRepl) super.dclText(sym)
713+
else {
714+
toText(sym) ~ {
715+
if (sym.is(Method)) toText(sym.info)
716+
else if (sym.isType && sym.info.isInstanceOf[TypeAlias]) toText(sym.info)
717+
else if (sym.isType || sym.isClass) ""
718+
else ":" ~~ toText(sym.info)
719+
}
720+
}
721+
}
722+
706723
override def kindString(sym: Symbol) = {
707724
val flags = sym.flagsUNSAFE
708725
if (flags is Package) "package"

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,6 @@ class UserFacingPrinter(_ctx: Context) extends RefinedPrinter(_ctx) {
1212
if (sym.name.isReplAssignName) nameString(sym.name)
1313
else keyString(sym) ~~ nameString(sym.name.stripModuleClassSuffix)
1414

15-
override def dclText(sym: Symbol): Text = toText(sym) ~ {
16-
if (sym.is(Method)) toText(sym.info)
17-
else if (sym.isType && sym.info.isInstanceOf[TypeAlias]) toText(sym.info)
18-
else if (sym.isType || sym.isClass) ""
19-
else ":" ~~ toText(sym.info)
20-
}
21-
22-
override def toText(const: Constant): Text = Str(const.value.toString)
23-
2415
override def toText(tp: Type): Text = tp match {
2516
case ExprType(result) => ":" ~~ toText(result)
2617
case tp => super.toText(tp)

0 commit comments

Comments
 (0)