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) {
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 @@ -640,11 +640,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
640
640
withEnclosingDef(constr) { addVparamssText(tparamsTxt ~~ modsText, vparamss) }
641
641
}
642
642
val parentsText = Text (parents map constrText, keywordStr(" with " ))
643
- val selfText = {
644
- val selfName = if (self.name == nme.WILDCARD ) keywordStr(" this" ) else self.name.toString
645
- (selfName ~ optText(self.tpt)(" : " ~ _) ~ " =>" ).close
646
- } provided (! self.isEmpty && ! constr.symbol.owner.is(Module ))
647
-
643
+ val selfText = selfToText(impl)
648
644
val body = if (ctx.settings.YtestPickler .value) {
649
645
// Pickling/unpickling reorders the body members, so we need to homogenize
650
646
val (params, rest) = impl.body partition {
@@ -661,6 +657,12 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
661
657
prefix ~ (keywordText(" extends" ) provided (! ofNew && parents.nonEmpty)) ~~ parentsText ~~ bodyText
662
658
}
663
659
660
+ protected def selfToText (impl : Template ): Text = {
661
+ val self = impl.self
662
+ val selfName = if (self.name == nme.WILDCARD ) keywordStr(" this" ) else self.name.toString
663
+ (selfName ~ optText(self.tpt)(" : " ~ _) ~ " =>" ).close provided (! self.isEmpty)
664
+ }
665
+
664
666
protected def templateText (tree : TypeDef , impl : Template ): Text = {
665
667
val decl = modText(tree.mods, keywordStr(if ((tree).mods is Trait ) " trait" else " class" ))
666
668
decl ~~ typeText(nameIdText(tree)) ~ withEnclosingDef(tree) { toTextTemplate(impl) } ~
You can’t perform that action at this time.
0 commit comments