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
221221 if (flags.isInline) this += " inline "
222222 if (flags.isOverride) this += " override "
223223
224- this += " def " += name
224+ val isConstructor = name == " <init>"
225+
226+ this += " def " += (if (isConstructor) " this" else name)
225227 printTargsDefs(targs)
226228 val it = argss.iterator
227229 while (it.hasNext)
228230 printArgsDefs(it.next())
229- this += " : "
230- printTypeTree(tpt)
231+ if (! isConstructor) {
232+ this += " : "
233+ printTypeTree(tpt)
234+ }
231235 rhs match {
232236 case Some (tree) =>
233237 this += " = "
@@ -264,7 +268,10 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
264268 printTree(expr)
265269
266270 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+ }
268275 this += " ("
269276 printTrees(args, " , " )
270277 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