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