File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed
compiler/src/dotty/tools/dotc/printing Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,9 @@ class DecompilerPrinter(_ctx: Context) extends RefinedPrinter(_ctx) {
5454 decl ~~ typeText(nameIdText(tree)) ~ withEnclosingDef(tree) { toTextTemplate(impl) } ~ " "
5555 }
5656
57+ override protected def selfToText (impl : Template ): Text =
58+ super .selfToText(impl).provided(! impl.constr.symbol.owner.is(Module ))
59+
5760 override protected def toTextTemplate (impl : Template , ofNew : Boolean = false ): Text = {
5861 def isSyntheticParent (sym : Symbol ): Boolean = {
5962 sym.maybeOwner == defn.ObjectClass ||
Original file line number Diff line number Diff line change @@ -649,11 +649,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
649649 withEnclosingDef(constr) { addVparamssText(tparamsTxt ~~ modsText, vparamss) }
650650 }
651651 val parentsText = Text (parents map constrText, keywordStr(" with " ))
652- val selfText = {
653- val selfName = if (self.name == nme.WILDCARD ) keywordStr(" this" ) else self.name.toString
654- (selfName ~ optText(self.tpt)(" : " ~ _) ~ " =>" ).close
655- } provided (! self.isEmpty && ! constr.symbol.owner.is(Module ))
656-
652+ val selfText = selfToText(impl)
657653 val body = if (ctx.settings.YtestPickler .value) {
658654 // Pickling/unpickling reorders the body members, so we need to homogenize
659655 val (params, rest) = impl.body partition {
@@ -670,6 +666,12 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
670666 prefix ~ (keywordText(" extends" ) provided (! ofNew && parents.nonEmpty)) ~~ parentsText ~~ bodyText
671667 }
672668
669+ protected def selfToText (impl : Template ): Text = {
670+ val self = impl.self
671+ val selfName = if (self.name == nme.WILDCARD ) keywordStr(" this" ) else self.name.toString
672+ (selfName ~ optText(self.tpt)(" : " ~ _) ~ " =>" ).close provided (! self.isEmpty)
673+ }
674+
673675 protected def templateText (tree : TypeDef , impl : Template ): Text = {
674676 val decl = modText(tree.mods, keywordStr(if ((tree).mods is Trait ) " trait" else " class" ))
675677 decl ~~ typeText(nameIdText(tree)) ~ withEnclosingDef(tree) { toTextTemplate(impl) } ~
You can’t perform that action at this time.
0 commit comments