Skip to content

Commit df00a67

Browse files
Merge pull request #4533 from fschueler/4526_class_w_compObj
Fix printing of classes with companion objects in the decompiler (#4526)
2 parents a681600 + a574431 commit df00a67

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class DecompilerPrinter(_ctx: Context) extends RefinedPrinter(_ctx) {
3838
}
3939
val statsText = stats match {
4040
case (pdef: PackageDef) :: Nil => toText(pdef)
41-
case _ => toTextGlobal(stats, "\n")
41+
case _ => Fluid(toTextGlobal(stats, "\n") :: Nil)
4242
}
4343
val bodyText =
4444
if (tree.pid.symbol.isEmptyPackage) statsText

tests/pos/classWithCompObj.decompiled

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

tests/pos/classWithCompObj.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class Foo
2+
object Foo

0 commit comments

Comments
 (0)