Skip to content

Commit a681600

Browse files
authored
Merge pull request #4532 from dieutth/is4526
Do not print class fields
2 parents 5d004dc + db93dcf commit a681600

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

compiler/src/dotty/tools/dotc/printing/DecompilerPrinter.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class DecompilerPrinter(_ctx: Context) extends RefinedPrinter(_ctx) {
6161
(sym == defn.ProductClass && impl.symbol.owner.is(Case))
6262
}
6363
val parents = impl.parents.filterNot(isSynthetic)
64+
val body = impl.body.filterNot(_.symbol.is(ParamAccessor))
6465

6566
// We don't print self type and constructor for objects
6667
val isObject = impl.constr.symbol.owner.is(Module)
@@ -69,7 +70,7 @@ class DecompilerPrinter(_ctx: Context) extends RefinedPrinter(_ctx) {
6970
val bodyText = " {" ~~ toTextGlobal(impl.body, "\n") ~ "}"
7071
parentsText.provided(parents.nonEmpty) ~ bodyText
7172
}
72-
else super.toTextTemplate(impl.copy(parents = parents), ofNew)
73+
else super.toTextTemplate(impl.copy(parents = parents, preBody = body), ofNew)
7374
}
7475

7576
override protected def typeApplyText[T >: Untyped](tree: TypeApply[T]): Text = {

tests/pos/i4526-2.decompiled

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/** Decompiled from out/posTestFromTasty/pos/i4526-2/Foo.class */
2+
class Foo(x: Int, y: Int) {}

tests/pos/i4526-2.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
class Foo(x: Int, y: Int)

0 commit comments

Comments
 (0)