Skip to content

Commit c98288f

Browse files
committed
Move some logic from UserFacingPrinter to RefinedPrinter
1 parent bb647b3 commit c98288f

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
@@ -697,6 +697,23 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
697697
super.toText(sym)
698698
}
699699

700+
override def toText(const: Constant): Text =
701+
if (!YprintRepl) super.toText(const)
702+
else if (const.tag == StringTag) Str('"' + const.value.toString + '"')
703+
else Str(const.value.toString)
704+
705+
override def dclText(sym: Symbol): Text = {
706+
if (!YprintRepl) super.dclText(sym)
707+
else {
708+
toText(sym) ~ {
709+
if (sym.is(Method)) toText(sym.info)
710+
else if (sym.isType && sym.info.isInstanceOf[TypeAlias]) toText(sym.info)
711+
else if (sym.isType || sym.isClass) ""
712+
else ":" ~~ toText(sym.info)
713+
}
714+
}
715+
}
716+
700717
override def kindString(sym: Symbol) = {
701718
val flags = sym.flagsUNSAFE
702719
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)