Skip to content

Commit 6971c0d

Browse files
committed
Fix double space in module diefinition printing
1 parent bcfc2b7 commit 6971c0d

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
640640
val tparamsTxt = withEnclosingDef(constr) { tparamsText(tparams) }
641641
val primaryConstrs = if (constr.rhs.isEmpty) Nil else constr :: Nil
642642
val prefix: Text =
643-
if (constr.symbol.owner.is(Module)) " "
643+
if (constr.symbol.owner.is(Module)) ""
644644
else if (vparamss.isEmpty || primaryConstrs.nonEmpty) tparamsTxt
645645
else {
646646
var modsText = modText(constr.mods, "")
@@ -661,7 +661,9 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
661661
params ::: rest
662662
} else impl.body
663663

664-
val bodyText = "{" ~~ selfText ~~ toTextGlobal(primaryConstrs ::: body, "\n") ~ "}"
664+
val bodyText =
665+
(if (constr.symbol.owner.is(Module)) " {" else "{") ~~
666+
selfText ~~ toTextGlobal(primaryConstrs ::: body, "\n") ~ "}"
665667

666668
prefix ~ (keywordText(" extends") provided (!ofNew && parents.nonEmpty)) ~~ parentsText ~~ bodyText
667669
}

tests/pos/simpleCaseObject.decompiled

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** Decompiled from out/posTestFromTasty/pos/simpleCaseObject/foo/Foo.class */
22
package foo {
3-
case object Foo {
3+
case object Foo {
44
override def hashCode(): Int = 1045991777
55
override def toString(): String = "Foo"
66
override def canEqual(that: Any): Boolean =

tests/run/puzzle.decompiled

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** Decompiled from out/runTestFromTasty/run/puzzle/Test.class */
2-
object Test {
2+
object Test {
33
def main(args: Array[String]): Unit =
44
{
55
println(if false then 5.0 else 53.0)

0 commit comments

Comments
 (0)