File tree 2 files changed +10
-5
lines changed
compiler/src/dotty/tools/dotc/printing 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) {
54
54
decl ~~ typeText(nameIdText(tree)) ~ withEnclosingDef(tree) { toTextTemplate(impl) } ~ " "
55
55
}
56
56
57
+ override protected def selfToText (impl : Template ): Text =
58
+ super .selfToText(impl).provided(! impl.constr.symbol.owner.is(Module ))
59
+
57
60
override protected def toTextTemplate (impl : Template , ofNew : Boolean = false ): Text = {
58
61
def isSyntheticParent (sym : Symbol ): Boolean = {
59
62
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) {
649
649
withEnclosingDef(constr) { addVparamssText(tparamsTxt ~~ modsText, vparamss) }
650
650
}
651
651
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)
657
653
val body = if (ctx.settings.YtestPickler .value) {
658
654
// Pickling/unpickling reorders the body members, so we need to homogenize
659
655
val (params, rest) = impl.body partition {
@@ -670,6 +666,12 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
670
666
prefix ~ (keywordText(" extends" ) provided (! ofNew && parents.nonEmpty)) ~~ parentsText ~~ bodyText
671
667
}
672
668
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
+
673
675
protected def templateText (tree : TypeDef , impl : Template ): Text = {
674
676
val decl = modText(tree.mods, keywordStr(if ((tree).mods is Trait ) " trait" else " class" ))
675
677
decl ~~ typeText(nameIdText(tree)) ~ withEnclosingDef(tree) { toTextTemplate(impl) } ~
You can’t perform that action at this time.
0 commit comments