Skip to content

Commit 3ca51ab

Browse files
committed
-YprintUser object instead of final module class with lazy val
1 parent 9bec5b2 commit 3ca51ab

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
@@ -480,7 +480,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
480480
modText(tree.mods, keywordStr(if (tree.mods is Mutable) "var" else "val")) ~~
481481
valDefText(nameIdText(tree)) ~ optAscription(tpt) ~
482482
withEnclosingDef(tree) { optText(tree.rhs)(" = " ~ _) }
483-
}
483+
}.provided(!YprintUser || !tree.symbol.is(Module))
484484
case tree @ DefDef(name, tparams, vparamss, tpt, _) =>
485485
dclTextOr {
486486
val printLambda = tree.symbol.isAnonymousFunction && YprintUser
@@ -498,8 +498,10 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
498498
}
499499
def recur(rhs: Tree, tparamsTxt: => Text): Text = rhs match {
500500
case impl: Template =>
501-
modText(tree.mods, keywordStr(if ((tree).mods is Trait) "trait" else "class")) ~~
502-
typeText(nameIdText(tree)) ~ withEnclosingDef(tree) { toTextTemplate(impl) } ~
501+
val decl =
502+
if (!YprintUser || !tree.mods.is(Module)) modText(tree.mods, keywordStr(if ((tree).mods is Trait) "trait" else "class"))
503+
else modText(tree.mods &~ (Final | Module), keywordStr("object"))
504+
decl ~~ typeText(nameIdText(tree)) ~ withEnclosingDef(tree) { toTextTemplate(impl) } ~
503505
(if (tree.hasType && ctx.settings.verbose.value) i"[decls = ${tree.symbol.info.decls}]" else "")
504506
case rhs: TypeBoundsTree =>
505507
typeDefText(tparamsTxt, toText(rhs))

0 commit comments

Comments
 (0)