Skip to content

Commit 97868f0

Browse files
committed
-YprintUser object instead of final module class with lazy val
1 parent 055000e commit 97868f0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
486486
modText(tree.mods, keywordStr(if (tree.mods is Mutable) "var" else "val")) ~~
487487
valDefText(nameIdText(tree)) ~ optAscription(tpt) ~
488488
withEnclosingDef(tree) { optText(tree.rhs)(" = " ~ _) }
489-
}
489+
}.provided(!YprintUser || !tree.symbol.is(Module))
490490
case tree @ DefDef(name, tparams, vparamss, tpt, _) =>
491491
dclTextOr {
492492
val printLambda = tree.symbol.isAnonymousFunction && YprintUser
@@ -504,8 +504,10 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
504504
}
505505
def recur(rhs: Tree, tparamsTxt: => Text): Text = rhs match {
506506
case impl: Template =>
507-
modText(tree.mods, keywordStr(if ((tree).mods is Trait) "trait" else "class")) ~~
508-
typeText(nameIdText(tree)) ~ withEnclosingDef(tree) { toTextTemplate(impl) } ~
507+
val decl =
508+
if (!YprintUser || !tree.mods.is(Module)) modText(tree.mods, keywordStr(if ((tree).mods is Trait) "trait" else "class"))
509+
else modText(tree.mods &~ (Final | Module), keywordStr("object"))
510+
decl ~~ typeText(nameIdText(tree)) ~ withEnclosingDef(tree) { toTextTemplate(impl) } ~
509511
(if (tree.hasType && ctx.settings.verbose.value) i"[decls = ${tree.symbol.info.decls}]" else "")
510512
case rhs: TypeBoundsTree =>
511513
typeDefText(tparamsTxt, toText(rhs))

0 commit comments

Comments
 (0)