Skip to content

Commit 1953180

Browse files
committed
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.
1 parent b822e4c commit 1953180

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
3636
}
3737
}
3838

39-
def homogenize(tree: Tree[_])(implicit ctx: Context) = tree match {
40-
case tree: tpd.Inlined if homogenizedView => Inliner.dropInlined(tree)
41-
case _ => tree
42-
}
43-
4439
private def enclDefIsClass = enclosingDef match {
4540
case owner: TypeDef[_] => owner.isClassDef
4641
case owner: untpd.ModuleDef => true
@@ -159,7 +154,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
159154
}
160155

161156
def blockText[T >: Untyped](trees: List[Tree[T]]): Text =
162-
"{" ~ toText(trees, "\n") ~ "}"
157+
("{" ~ toText(trees, "\n") ~ "}").close
163158

164159
override def toText[T >: Untyped](tree: Tree[T]): Text = controlled {
165160

@@ -274,7 +269,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
274269
if (homogenizedView && pid.hasType) toTextLocal(pid.tpe)
275270
else toTextLocal(pid)
276271

277-
var txt: Text = homogenize(tree) match {
272+
def toTextCore(tree: Tree): Text = tree match {
278273
case id: Trees.BackquotedIdent[_] if !homogenizedView =>
279274
"`" ~ toText(id.name) ~ "`"
280275
case Ident(name) =>
@@ -349,8 +344,9 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
349344
}
350345
case SeqLiteral(elems, elemtpt) =>
351346
"[" ~ toTextGlobal(elems, ",") ~ " : " ~ toText(elemtpt) ~ "]"
352-
case Inlined(call, bindings, body) =>
353-
"/* inlined from " ~ toText(call) ~ "*/ " ~ blockText(bindings :+ body)
347+
case tree @ Inlined(call, bindings, body) =>
348+
if (homogenizedView) toTextCore(Inliner.dropInlined(tree.asInstanceOf[tpd.Inlined]))
349+
else "/* inlined from " ~ toText(call) ~ "*/ " ~ blockText(bindings :+ body)
354350
case tpt: untpd.DerivedTypeTree =>
355351
"<derived typetree watching " ~ summarized(toText(tpt.watched)) ~ ">"
356352
case TypeTree(orig) =>
@@ -518,13 +514,14 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
518514
case _ =>
519515
tree.fallbackToText(this)
520516
}
517+
var txt = toTextCore(tree)
521518
if (ctx.settings.printtypes.value && tree.hasType) {
522519
val tp = tree.typeOpt match {
523520
case tp: TermRef if tree.isInstanceOf[RefTree] && !tp.denot.isOverloaded => tp.underlying
524521
case tp => tp
525522
}
526523
if (tree.isType) txt = toText(tp)
527-
else if (!tree.isDef) txt = "<" ~ txt ~ ":" ~ toText(tp) ~ ">"
524+
else if (!tree.isDef) txt = ("<" ~ txt ~ ":" ~ toText(tp) ~ ">").close
528525
}
529526
if (ctx.settings.Yprintpos.value && !tree.isInstanceOf[WithoutTypeOrPos[_]])
530527
txt = txt ~ "@" ~ tree.pos.toString

0 commit comments

Comments
 (0)