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 @@ -221,13 +221,17 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
221
221
if (flags.isInline) this += " inline "
222
222
if (flags.isOverride) this += " override "
223
223
224
- this += " def " += name
224
+ val isConstructor = name == " <init>"
225
+
226
+ this += " def " += (if (isConstructor) " this" else name)
225
227
printTargsDefs(targs)
226
228
val it = argss.iterator
227
229
while (it.hasNext)
228
230
printArgsDefs(it.next())
229
- this += " : "
230
- printTypeTree(tpt)
231
+ if (! isConstructor) {
232
+ this += " : "
233
+ printTypeTree(tpt)
234
+ }
231
235
rhs match {
232
236
case Some (tree) =>
233
237
this += " = "
@@ -264,7 +268,10 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
264
268
printTree(expr)
265
269
266
270
case Term .Apply (fn, args) =>
267
- printTree(fn)
271
+ fn match {
272
+ case Term .Select (Term .This (_), " <init>" , _) => this += " this" // call to constructor inside a constructor
273
+ case _ => printTree(fn)
274
+ }
268
275
this += " ("
269
276
printTrees(args, " , " )
270
277
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