@@ -146,14 +146,34 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
146146 case stat@ Import (_, _) => stat
147147 case stat@ Term () => stat
148148 }
149- if (stats1.nonEmpty) {
149+
150+ def printBody (printSelf : Boolean ) = {
150151 this += " {"
151152 indented {
153+ if (printSelf) {
154+ val Some (ValDef (name, tpt, _)) = self
155+ indented {
156+ val name1 = if (name == " _" ) " this" else name
157+ this += " " += name1 += " : "
158+ printTypeTree(tpt)
159+ this += " =>"
160+ }
161+ }
152162 this += lineBreak()
153163 printTrees(stats1, lineBreak())
154164 }
155165 this += lineBreak() += " }"
156166 }
167+ self match {
168+ case Some (ValDef (_, TypeTree .Singleton (_), _)) =>
169+ if (stats1.nonEmpty)
170+ printBody(printSelf = false )
171+ case Some (ValDef (_, _, _)) =>
172+ printBody(printSelf = true )
173+ case _ =>
174+ if (stats1.nonEmpty)
175+ printBody(printSelf = false )
176+ }
157177 this
158178
159179 case tdef @ TypeDef (name, rhs) =>
@@ -875,10 +895,18 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
875895 printType(tp)
876896
877897 case Type .ThisType (tp) =>
878- printType(tp)
879898 tp match {
880- case Type .SymRef (cdef @ ClassDef (_, _, _, _, _), _) if ! cdef.flags.isObject => this += " .this"
881- case _ => this
899+ case Type .SymRef (cdef @ ClassDef (name, _, _, _, _), prefix) if ! cdef.flags.isObject =>
900+ def printPrefix (prefix : TypeOrBounds ): Unit = prefix match {
901+ case Type .SymRef (ClassDef (name, _, _, _, _), prefix2) =>
902+ printPrefix(prefix2)
903+ this += name += " ."
904+ case _ =>
905+ }
906+ printPrefix(prefix)
907+ this += name
908+ this += " .this"
909+ case _ => printType(tp)
882910 }
883911
884912 case Type .TypeLambda (paramNames, tparams, body) =>
0 commit comments