diff options
author | Guillaume Martres <smarter@ubuntu.com> | 2016-11-14 23:32:35 +0100 |
---|---|---|
committer | Guillaume Martres <smarter@ubuntu.com> | 2016-11-22 01:35:08 +0100 |
commit | a7d25b9eb8f4d6eca84bdeb32227e427a9de5072 (patch) | |
tree | 5a9cba2cedbb02b2189c6c6299964a1bd53efa70 /compiler | |
parent | 46f482ebda7aceac2a5f3fb885916a13b95907ca (diff) | |
download | dotty-a7d25b9eb8f4d6eca84bdeb32227e427a9de5072.tar.gz dotty-a7d25b9eb8f4d6eca84bdeb32227e427a9de5072.tar.bz2 dotty-a7d25b9eb8f4d6eca84bdeb32227e427a9de5072.zip |
-Ytest-pickler: homogenize template body output order
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala | 15 |
1 files changed, 14 insertions, 1 deletions
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 } |