@@ -640,16 +640,18 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
640
640
val tparamsTxt = withEnclosingDef(constr) { tparamsText(tparams) }
641
641
val primaryConstrs = if (constr.rhs.isEmpty) Nil else constr :: Nil
642
642
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
645
644
else {
646
645
var modsText = modText(constr.mods, " " )
647
646
if (! modsText.isEmpty) modsText = " " ~ modsText
648
647
if (constr.mods.hasAnnotations && ! constr.mods.hasFlags) modsText = modsText ~~ " this"
649
648
withEnclosingDef(constr) { addVparamssText(tparamsTxt ~~ modsText, vparamss) }
650
649
}
651
650
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)
653
655
val body = if (ctx.settings.YtestPickler .value) {
654
656
// Pickling/unpickling reorders the body members, so we need to homogenize
655
657
val (params, rest) = impl.body partition {
@@ -661,19 +663,11 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
661
663
params ::: rest
662
664
} else impl.body
663
665
664
- val bodyText =
665
- (if (constr.symbol.owner.is(Module )) " {" else " {" ) ~~
666
- selfText ~~ toTextGlobal(primaryConstrs ::: body, " \n " ) ~ " }"
666
+ val bodyText = " {" ~~ selfText ~~ toTextGlobal(primaryConstrs ::: body, " \n " ) ~ " }"
667
667
668
668
prefix ~ (keywordText(" extends" ) provided (! ofNew && parents.nonEmpty)) ~~ parentsText ~~ bodyText
669
669
}
670
670
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)
675
- }
676
-
677
671
protected def templateText (tree : TypeDef , impl : Template ): Text = {
678
672
val decl = modText(tree.mods, keywordStr(if ((tree).mods is Trait ) " trait" else " class" ))
679
673
decl ~~ typeText(nameIdText(tree)) ~ withEnclosingDef(tree) { toTextTemplate(impl) } ~
0 commit comments