File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed
library/src/scala/tasty/util Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -222,13 +222,17 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
222
222
if (flags.isInline) this += " inline "
223
223
if (flags.isOverride) this += " override "
224
224
225
- this += " def " += name
225
+ val isConstructor = name == " <init>"
226
+
227
+ this += " def " += (if (isConstructor) " this" else name)
226
228
printTargsDefs(targs)
227
229
val it = argss.iterator
228
230
while (it.hasNext)
229
231
printArgsDefs(it.next())
230
- this += " : "
231
- printTypeTree(tpt)
232
+ if (! isConstructor) {
233
+ this += " : "
234
+ printTypeTree(tpt)
235
+ }
232
236
rhs match {
233
237
case Some (tree) =>
234
238
this += " = "
@@ -265,7 +269,10 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
265
269
printTree(expr)
266
270
267
271
case Term .Apply (fn, args) =>
268
- printTree(fn)
272
+ fn match {
273
+ case Term .Select (Term .This (_), " <init>" , _) => this += " this" // call to constructor inside a constructor
274
+ case _ => printTree(fn)
275
+ }
269
276
this += " ("
270
277
printTrees(args, " , " )
271
278
this += " )"
Original file line number Diff line number Diff line change
1
+ /** Decompiled from out/posTestFromTasty/pos/t116/C.class */
2
+ class C() {
3
+ def this(x: scala.Int) = {
4
+ this()
5
+ class D() extends C()
6
+ ()
7
+ }
8
+ }
You can’t perform that action at this time.
0 commit comments