From 2575d11bd1a670ace8bd7e91777ea135759af51f Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 13 Oct 2016 09:39:44 +0200 Subject: Preserve all positions in Tasty. The goal is that pickled and unpickled trees should print the same with -Yprintpos. There are several reasons why this is not the case so far. Some of them are fixed in this commit. --- src/dotty/tools/dotc/printing/RefinedPrinter.scala | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/dotty/tools/dotc/printing/RefinedPrinter.scala') diff --git a/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/src/dotty/tools/dotc/printing/RefinedPrinter.scala index 6315cfabc..7f88e246b 100644 --- a/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -426,7 +426,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { case _ => toTextGlobal(sel) } val selectorsText: Text = selectors match { - case Ident(name) :: Nil => toText(name) + case id :: Nil => toText(id) case _ => "{" ~ Text(selectors map selectorText, ", ") ~ "}" } "import " ~ toTextLocal(expr) ~ "." ~ selectorsText @@ -525,8 +525,10 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { if (tree.isType) txt = toText(tp) else if (!tree.isDef) txt = ("<" ~ txt ~ ":" ~ toText(tp) ~ ">").close } - if (ctx.settings.Yprintpos.value && !tree.isInstanceOf[WithoutTypeOrPos[_]]) - txt = txt ~ "@" ~ tree.pos.toString + if (ctx.settings.Yprintpos.value && !tree.isInstanceOf[WithoutTypeOrPos[_]]) { + val pos = if (homogenizedView) tree.pos.toSynthetic else tree.pos + txt = txt ~ "@" ~ pos.toString + } tree match { case Block(_, _) | Template(_, _, _, _) => txt case _ => txt.close -- cgit v1.2.3