Skip to content

Commit 376d325

Browse files
committed
Print TypeDefs from trees
As is already the case for the other member defs, use the right hand side instead of the symbol's type.
1 parent 646453a commit 376d325

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,8 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
458458
case ByNameTypeTree(tpt) =>
459459
"=> " ~ toTextLocal(tpt)
460460
case TypeBoundsTree(lo, hi) =>
461-
optText(lo)(" >: " ~ _) ~ optText(hi)(" <: " ~ _)
461+
if (lo eq hi) optText(lo)(" = " ~ _)
462+
else optText(lo)(" >: " ~ _) ~ optText(hi)(" <: " ~ _)
462463
case Bind(name, body) =>
463464
changePrec(InfixPrec) { toText(name) ~ " @ " ~ toText(body) }
464465
case Alternative(trees) =>
@@ -489,10 +490,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
489490
def typeDefText(tparamsText: => Text, rhsText: => Text) =
490491
dclTextOr {
491492
modText(tree.mods, keywordStr("type")) ~~ (varianceText(tree.mods) ~ typeText(nameIdText(tree))) ~
492-
withEnclosingDef(tree) {
493-
if (tree.hasType) toText(tree.symbol.info) // TODO: always print RHS, once we pickle/unpickle type trees
494-
else tparamsText ~ rhsText
495-
}
493+
withEnclosingDef(tree) { tparamsText ~ rhsText }
496494
}
497495
def recur(rhs: Tree, tparamsTxt: => Text): Text = rhs match {
498496
case impl: Template =>
@@ -503,6 +501,8 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
503501
typeDefText(tparamsTxt, toText(rhs))
504502
case LambdaTypeTree(tparams, body) =>
505503
recur(body, tparamsText(tparams))
504+
case rhs: TypeTree if rhs.tpe.isInstanceOf[TypeBounds] =>
505+
typeDefText(tparamsTxt, toText(rhs))
506506
case rhs =>
507507
typeDefText(tparamsTxt, optText(rhs)(" = " ~ _))
508508
}

0 commit comments

Comments
 (0)