@@ -146,14 +146,34 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
146
146
case stat@ Import (_, _) => stat
147
147
case stat@ Term () => stat
148
148
}
149
- if (stats1.nonEmpty) {
149
+
150
+ def printBody (printSelf : Boolean ) = {
150
151
this += " {"
151
152
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
+ }
152
162
this += lineBreak()
153
163
printTrees(stats1, lineBreak())
154
164
}
155
165
this += lineBreak() += " }"
156
166
}
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
+ }
157
177
this
158
178
159
179
case tdef @ TypeDef (name, rhs) =>
@@ -875,10 +895,18 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
875
895
printType(tp)
876
896
877
897
case Type .ThisType (tp) =>
878
- printType(tp)
879
898
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)
882
910
}
883
911
884
912
case Type .TypeLambda (paramNames, tparams, body) =>
0 commit comments