aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-10-25 14:20:19 +0200
committerMartin Odersky <odersky@gmail.com>2013-10-25 14:20:19 +0200
commit8c1cc60c7ef9c13b312fceaf6cb8c8c129753344 (patch)
treea124ce408dac44b94e02b3f3c62509ab4f1415bf
parente8a160c8c64354b12423b908067a1ba328d6248f (diff)
downloaddotty-8c1cc60c7ef9c13b312fceaf6cb8c8c129753344.tar.gz
dotty-8c1cc60c7ef9c13b312fceaf6cb8c8c129753344.tar.bz2
dotty-8c1cc60c7ef9c13b312fceaf6cb8c8c129753344.zip
Refinement to tree printing of refs.
When printing the type of a non-overloaded RefTree (Ident, Select, SelectFromTypeTree), the reference itself is no longer printed.
-rw-r--r--src/dotty/tools/dotc/printing/RefinedPrinter.scala11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/src/dotty/tools/dotc/printing/RefinedPrinter.scala
index 184a10300..0e2eb77f2 100644
--- a/src/dotty/tools/dotc/printing/RefinedPrinter.scala
+++ b/src/dotty/tools/dotc/printing/RefinedPrinter.scala
@@ -364,9 +364,14 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
case _ =>
tree.fallbackToText(this)
}
- if (ctx.settings.printtypes.value && tree.hasType)
- if (tree.isType) txt = toText(tree.typeOpt)
- else if (!tree.isDef) txt = "<" ~ txt ~ ":" ~ toText(tree.typeOpt) ~ ">"
+ if (ctx.settings.printtypes.value && tree.hasType) {
+ val tp = tree.typeOpt match {
+ case tp: TermRef if tree.isInstanceOf[RefTree] && !tp.denot.isOverloaded => tp.underlying
+ case tp => tp
+ }
+ if (tree.isType) txt = toText(tp)
+ else if (!tree.isDef) txt = "<" ~ txt ~ ":" ~ toText(tp) ~ ">"
+ }
tree match {
case Block(_, _) | Template(_, _, _, _) => txt
case _ => txt.close