@@ -161,7 +161,12 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
161161 implicit def modsDeco (mdef : untpd.MemberDef )(implicit ctx : Context ): untpd.ModsDeco =
162162 tpd.modsDeco(mdef.asInstanceOf [tpd.MemberDef ]).asInstanceOf [untpd.ModsDeco ]
163163
164- def optDotPrefix (name : Name ) = optText(name)(_ ~ " ." )
164+ def isLocalThis (tree : Tree ) = tree.typeOpt match {
165+ case tp : ThisType => tp.cls == ctx.owner.enclosingClass
166+ case _ => false
167+ }
168+
169+ def optDotPrefix (tree : This ) = optText(tree.qual)(_ ~ " ." ) provided ! isLocalThis(tree)
165170
166171 def optAscription (tpt : untpd.Tree ) = optText(tpt)(" : " ~ _)
167172 // Dotty deviation: called with an untpd.Tree, so cannot be a untpd.Tree[T] (seems to be a Scala2 problem to allow this)
@@ -268,14 +273,10 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
268273 }
269274 case tree @ Select (qual, name) =>
270275 toTextLocal(qual) ~ (" ." ~ nameIdText(tree) provided name != nme.CONSTRUCTOR )
271- case This (name) =>
272- val isLocal = tree.typeOpt match {
273- case tp : ThisType => tp.cls == ctx.owner.enclosingClass
274- case _ => false
275- }
276- (optDotPrefix(name) provided ! isLocal) ~ " this" ~ idText(tree)
277- case Super (This (name), mix) =>
278- optDotPrefix(name) ~ " super" ~ optText(mix)(" [" ~ _ ~ " ]" )
276+ case tree : This =>
277+ optDotPrefix(tree) ~ " this" ~ idText(tree)
278+ case Super (qual : This , mix) =>
279+ optDotPrefix(qual) ~ " super" ~ optText(mix)(" [" ~ _ ~ " ]" )
279280 case Apply (fun, args) =>
280281 toTextLocal(fun) ~ " (" ~ toTextGlobal(args, " , " ) ~ " )"
281282 case TypeApply (fun, args) =>
0 commit comments