aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/printing/RefinedPrinter.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-10-13 09:39:44 +0200
committerMartin Odersky <odersky@gmail.com>2016-10-15 19:33:51 +0200
commit2575d11bd1a670ace8bd7e91777ea135759af51f (patch)
tree57d705b50023fecc44247b6ace8ddf9f7865f336 /src/dotty/tools/dotc/printing/RefinedPrinter.scala
parent8bfaadaae141e83db7f515b042fcee26ed0e54fd (diff)
downloaddotty-2575d11bd1a670ace8bd7e91777ea135759af51f.tar.gz
dotty-2575d11bd1a670ace8bd7e91777ea135759af51f.tar.bz2
dotty-2575d11bd1a670ace8bd7e91777ea135759af51f.zip
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.
Diffstat (limited to 'src/dotty/tools/dotc/printing/RefinedPrinter.scala')
-rw-r--r--src/dotty/tools/dotc/printing/RefinedPrinter.scala8
1 files changed, 5 insertions, 3 deletions
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