@@ -640,16 +640,18 @@ 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 )) " "
644- else if (vparamss.isEmpty || primaryConstrs.nonEmpty) tparamsTxt
643+ if (vparamss.isEmpty || primaryConstrs.nonEmpty) tparamsTxt
645644 else {
646645 var modsText = modText(constr.mods, " " )
647646 if (! modsText.isEmpty) modsText = " " ~ modsText
648647 if (constr.mods.hasAnnotations && ! constr.mods.hasFlags) modsText = modsText ~~ " this"
649648 withEnclosingDef(constr) { addVparamssText(tparamsTxt ~~ modsText, vparamss) }
650649 }
651650 val parentsText = Text (parents map constrText, keywordStr(" with " ))
652- val selfText = selfToText(impl)
651+ val selfText = {
652+ val selfName = if (self.name == nme.WILDCARD ) keywordStr(" this" ) else self.name.toString
653+ (selfName ~ optText(self.tpt)(" : " ~ _) ~ " =>" ).close
654+ }.provided(! self.isEmpty)
653655 val body = if (ctx.settings.YtestPickler .value) {
654656 // Pickling/unpickling reorders the body members, so we need to homogenize
655657 val (params, rest) = impl.body partition {
@@ -661,17 +663,9 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
661663 params ::: rest
662664 } else impl.body
663665
664- val bodyText =
665- (if (constr.symbol.owner.is(Module )) " {" else " {" ) ~~
666- selfText ~~ toTextGlobal(primaryConstrs ::: body, " \n " ) ~ " }"
667-
668- prefix ~ (keywordText(" extends" ) provided (! ofNew && parents.nonEmpty)) ~~ parentsText ~~ bodyText
669- }
666+ val bodyText = " {" ~~ selfText ~~ toTextGlobal(primaryConstrs ::: body, " \n " ) ~ " }"
670667
671- protected def selfToText (impl : Template ): Text = {
672- val self = impl.self
673- val selfName = if (self.name == nme.WILDCARD ) keywordStr(" this" ) else self.name.toString
674- (selfName ~ optText(self.tpt)(" : " ~ _) ~ " =>" ).close provided (! self.isEmpty)
668+ prefix ~ keywordText(" extends" ).provided(! ofNew && parents.nonEmpty) ~~ parentsText ~ bodyText
675669 }
676670
677671 protected def templateText (tree : TypeDef , impl : Template ): Text = {
0 commit comments