From db93dcf919c26000d8e2f7e2c5c24bf5993384fd Mon Sep 17 00:00:00 2001 From: dieutth Date: Tue, 15 May 2018 08:41:48 -0400 Subject: [PATCH] Do not print class fields * Partly fix i4526 --- compiler/src/dotty/tools/dotc/printing/DecompilerPrinter.scala | 3 ++- tests/pos/i4526-2.decompiled | 2 ++ tests/pos/i4526-2.scala | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i4526-2.decompiled create mode 100644 tests/pos/i4526-2.scala diff --git a/compiler/src/dotty/tools/dotc/printing/DecompilerPrinter.scala b/compiler/src/dotty/tools/dotc/printing/DecompilerPrinter.scala index 13ec0f15cfdc..7d2eb82be166 100644 --- a/compiler/src/dotty/tools/dotc/printing/DecompilerPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/DecompilerPrinter.scala @@ -61,6 +61,7 @@ class DecompilerPrinter(_ctx: Context) extends RefinedPrinter(_ctx) { (sym == defn.ProductClass && impl.symbol.owner.is(Case)) } val parents = impl.parents.filterNot(isSynthetic) + val body = impl.body.filterNot(_.symbol.is(ParamAccessor)) // We don't print self type and constructor for objects val isObject = impl.constr.symbol.owner.is(Module) @@ -69,7 +70,7 @@ class DecompilerPrinter(_ctx: Context) extends RefinedPrinter(_ctx) { val bodyText = " {" ~~ toTextGlobal(impl.body, "\n") ~ "}" parentsText.provided(parents.nonEmpty) ~ bodyText } - else super.toTextTemplate(impl.copy(parents = parents), ofNew) + else super.toTextTemplate(impl.copy(parents = parents, preBody = body), ofNew) } override protected def typeApplyText[T >: Untyped](tree: TypeApply[T]): Text = { diff --git a/tests/pos/i4526-2.decompiled b/tests/pos/i4526-2.decompiled new file mode 100644 index 000000000000..b53220574bf5 --- /dev/null +++ b/tests/pos/i4526-2.decompiled @@ -0,0 +1,2 @@ +/** Decompiled from out/posTestFromTasty/pos/i4526-2/Foo.class */ +class Foo(x: Int, y: Int) {} diff --git a/tests/pos/i4526-2.scala b/tests/pos/i4526-2.scala new file mode 100644 index 000000000000..4ea1f545bf71 --- /dev/null +++ b/tests/pos/i4526-2.scala @@ -0,0 +1 @@ +class Foo(x: Int, y: Int)