diff options
author | Martin Odersky <odersky@gmail.com> | 2016-09-06 13:04:08 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-10-02 16:11:21 +0200 |
commit | bd0660ef100ee1a41bd56267d9e95c9e6dd74d5e (patch) | |
tree | e3c32ce142fa41280ea8bee54e4e8d063b3531c7 /src | |
parent | d96cb84c35bfe47718850c1b8db435e67d512a0e (diff) | |
download | dotty-bd0660ef100ee1a41bd56267d9e95c9e6dd74d5e.tar.gz dotty-bd0660ef100ee1a41bd56267d9e95c9e6dd74d5e.tar.bz2 dotty-bd0660ef100ee1a41bd56267d9e95c9e6dd74d5e.zip |
Juggling with close in RefinedPrinter
Because of different close seqences before and after pickling
we could get spurious differences, where in one file things were
put on one line, and in the pther there was a linebreak.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/printing/RefinedPrinter.scala | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/src/dotty/tools/dotc/printing/RefinedPrinter.scala index f4a7a4dc5..4f3a8d272 100644 --- a/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -36,11 +36,6 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { } } - def homogenize(tree: Tree[_])(implicit ctx: Context) = tree match { - case tree: tpd.Inlined if homogenizedView => Inliner.dropInlined(tree) - case _ => tree - } - private def enclDefIsClass = enclosingDef match { case owner: TypeDef[_] => owner.isClassDef case owner: untpd.ModuleDef => true @@ -159,7 +154,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { } def blockText[T >: Untyped](trees: List[Tree[T]]): Text = - "{" ~ toText(trees, "\n") ~ "}" + ("{" ~ toText(trees, "\n") ~ "}").close override def toText[T >: Untyped](tree: Tree[T]): Text = controlled { @@ -282,7 +277,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { if (homogenizedView && pid.hasType) toTextLocal(pid.tpe) else toTextLocal(pid) - var txt: Text = homogenize(tree) match { + def toTextCore(tree: Tree): Text = tree match { case id: Trees.BackquotedIdent[_] if !homogenizedView => "`" ~ toText(id.name) ~ "`" case Ident(name) => @@ -356,8 +351,9 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { } case SeqLiteral(elems, elemtpt) => "[" ~ toTextGlobal(elems, ",") ~ " : " ~ toText(elemtpt) ~ "]" - case Inlined(call, bindings, body) => - "/* inlined from " ~ toText(call) ~ "*/ " ~ blockText(bindings :+ body) + case tree @ Inlined(call, bindings, body) => + if (homogenizedView) toTextCore(Inliner.dropInlined(tree.asInstanceOf[tpd.Inlined])) + else "/* inlined from " ~ toText(call) ~ "*/ " ~ blockText(bindings :+ body) case tpt: untpd.DerivedTypeTree => "<derived typetree watching " ~ summarized(toText(tpt.watched)) ~ ">" case TypeTree(orig) => @@ -521,13 +517,14 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { case _ => tree.fallbackToText(this) } + var txt = toTextCore(tree) 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) ~ ">" + else if (!tree.isDef) txt = ("<" ~ txt ~ ":" ~ toText(tp) ~ ">").close } if (ctx.settings.Yprintpos.value && !tree.isInstanceOf[WithoutTypeOrPos[_]]) txt = txt ~ "@" ~ tree.pos.toString |