Skip to content

Commit 5a14ce2

Browse files
committed
Fix pinting of secondary constructors
1 parent 6f37182 commit 5a14ce2

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

compiler/test/dotty/tools/dotc/FromTastyTests.scala

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ class FromTastyTests extends ParallelTesting {
139139
"erased-asInstanceOf",
140140
"erased-extension-method",
141141
"erased-lub",
142-
"erasure",
143142
"ErasureAnd",
144143
"explicitOuter",
145144
"extmethods",
@@ -155,7 +154,6 @@ class FromTastyTests extends ParallelTesting {
155154
"hklower",
156155
"hkrange",
157156
"ho-implicits",
158-
"homonym",
159157
"i0239",
160158
"i1044",
161159
"i1216",
@@ -212,7 +210,6 @@ class FromTastyTests extends ParallelTesting {
212210
"i3083",
213211
"i3139",
214212
"i3149",
215-
"i3171",
216213
"i3207",
217214
"i3246",
218215
"i3248",
@@ -276,7 +273,6 @@ class FromTastyTests extends ParallelTesting {
276273
"javaConversions-2.10-ambiguity",
277274
"javaConversions-2.10-regression",
278275
"Labels",
279-
"lambdalift-1",
280276
"lazyValsSepComp",
281277
"macro-deprecate-dont-touch-backquotedidents",
282278
"Meter",
@@ -290,7 +286,6 @@ class FromTastyTests extends ParallelTesting {
290286
"Orderings",
291287
"overloaddefault",
292288
"overloaded_ho_fun",
293-
"override-via-self",
294289
"package-case",
295290
"packageobject",
296291
"packageobjs",
@@ -357,7 +352,6 @@ class FromTastyTests extends ParallelTesting {
357352
"t1107a",
358353
"t1136",
359354
"t1147",
360-
"t116",
361355
"t1164",
362356
"t1168",
363357
"t1208",
@@ -369,11 +363,8 @@ class FromTastyTests extends ParallelTesting {
369363
"t1318",
370364
"t1391",
371365
"t1438",
372-
"t160",
373-
"t175",
374366
"t1756",
375367
"t1789",
376-
"t1798",
377368
"t1858",
378369
"t1957",
379370
"t1974",
@@ -416,7 +407,6 @@ class FromTastyTests extends ParallelTesting {
416407
"t3174b",
417408
"t3177",
418409
"t319",
419-
"t3274",
420410
"t3312",
421411
"t3343",
422412
"t3374",
@@ -488,7 +478,6 @@ class FromTastyTests extends ParallelTesting {
488478
"t6575b",
489479
"t6600",
490480
"t661",
491-
"t6745",
492481
"t6797",
493482
"t690",
494483
"t6921",
@@ -516,7 +505,6 @@ class FromTastyTests extends ParallelTesting {
516505
"t7753",
517506
"t7785",
518507
"t7815",
519-
"t7853",
520508
"t7864",
521509
"t789",
522510
"t7902",
@@ -672,7 +660,6 @@ class FromTastyTests extends ParallelTesting {
672660
"concat-two-strings",
673661
"concurrent-map-conversions",
674662
"config",
675-
"constructors",
676663
"contrib674",
677664
"correct-bind",
678665
"Course-2002-03",
@@ -839,7 +826,6 @@ class FromTastyTests extends ParallelTesting {
839826
"t1505",
840827
"t1591",
841828
"t1672",
842-
"t1909b",
843829
"t1939",
844830
"t1987",
845831
"t1994",
@@ -869,7 +855,6 @@ class FromTastyTests extends ParallelTesting {
869855
"t3613",
870856
"t3651",
871857
"t3763",
872-
"t3832",
873858
"t3855",
874859
"t3935",
875860
"t4013",

library/src/scala/tasty/util/ShowSourceCode.scala

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,17 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
239239
if (flags.isInline) this += "inline "
240240
if (flags.isOverride) this += "override "
241241

242-
this += "def " += name
242+
val isConstructor = name == "<init>"
243+
244+
this += "def " += (if (isConstructor) "this" else name)
243245
printTargsDefs(targs)
244246
val it = argss.iterator
245247
while (it.hasNext)
246248
printArgsDefs(it.next())
247-
this += ": "
248-
printTypeTree(tpt)
249+
if (!isConstructor) {
250+
this += ": "
251+
printTypeTree(tpt)
252+
}
249253
rhs match {
250254
case Some(tree) =>
251255
this += " = "
@@ -288,7 +292,10 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
288292
printTree(expr)
289293

290294
case Term.Apply(fn, args) =>
291-
printTree(fn)
295+
fn match {
296+
case Term.Select(Term.This(_), "<init>", _) => this += "this" // call to constructor inside a constructor
297+
case _ => printTree(fn)
298+
}
292299
this += "("
293300
printTrees(args, ", ")
294301
this += ")"

tests/pos/t116.decompiled

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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+
}

0 commit comments

Comments
 (0)