From a7d25b9eb8f4d6eca84bdeb32227e427a9de5072 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Mon, 14 Nov 2016 23:32:35 +0100 Subject: -Ytest-pickler: homogenize template body output order --- .../src/dotty/tools/dotc/printing/RefinedPrinter.scala | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala index 29e1d4869..00627fc28 100644 --- a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -288,7 +288,20 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { val selfName = if (self.name == nme.WILDCARD) "this" else self.name.toString (selfName ~ optText(self.tpt)(": " ~ _) ~ " =>").close } provided !self.isEmpty - val bodyText = "{" ~~ selfText ~~ toTextGlobal(primaryConstrs ::: impl.body, "\n") ~ "}" + + val body = if (ctx.settings.YtestPickler.value) { + // Pickling/unpickling reorders the body members, so we need to homogenize + val (params, rest) = impl.body partition { + case stat: TypeDef => stat.symbol.is(Param) + case stat: ValOrDefDef => + stat.symbol.is(ParamAccessor) && !stat.symbol.isSetter + case _ => false + } + params ::: rest + } else impl.body + + val bodyText = "{" ~~ selfText ~~ toTextGlobal(primaryConstrs ::: body, "\n") ~ "}" + prefix ~ (" extends" provided !ofNew) ~~ parentsText ~~ bodyText } -- cgit v1.2.3