Skip to content

Commit 6f37182

Browse files
committed
Print self types
1 parent ceae7da commit 6f37182

File tree

3 files changed

+31
-14
lines changed

3 files changed

+31
-14
lines changed

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ class FromTastyTests extends ParallelTesting {
193193
"i2300",
194194
"i2378",
195195
"i239-packageObj",
196-
"i2390",
197196
"i2397",
198197
"i2468",
199198
"i2554",
@@ -313,9 +312,6 @@ class FromTastyTests extends ParallelTesting {
313312
"sammy_single",
314313
"sams",
315314
"scala-singleton",
316-
"scoping1",
317-
"scoping3",
318-
"selftypes",
319315
"seq-ordering",
320316
"SI-4012-a",
321317
"SI-4012-b",
@@ -354,11 +350,11 @@ class FromTastyTests extends ParallelTesting {
354350
"t1014",
355351
"t1027",
356352
"t1035",
353+
"t1050",
357354
"t1053",
358355
"t1070",
359356
"t1085",
360357
"t1107a",
361-
"t1131",
362358
"t1136",
363359
"t1147",
364360
"t116",
@@ -401,7 +397,6 @@ class FromTastyTests extends ParallelTesting {
401397
"t2454",
402398
"t2484",
403399
"t2503",
404-
"t2545",
405400
"t2610",
406401
"t2613",
407402
"t2660",
@@ -411,8 +406,6 @@ class FromTastyTests extends ParallelTesting {
411406
"t2712-3",
412407
"t2712-5",
413408
"t2712-7",
414-
"t2795-new",
415-
"t2795-old",
416409
"t287",
417410
"t2910",
418411
"t2945",
@@ -426,14 +419,12 @@ class FromTastyTests extends ParallelTesting {
426419
"t3274",
427420
"t3312",
428421
"t3343",
429-
"t3371",
430422
"t3374",
431423
"t3384",
432424
"t3430",
433425
"t3528",
434426
"t3560",
435427
"t3570",
436-
"t360",
437428
"t361",
438429
"t3672",
439430
"t3777",
@@ -459,7 +450,6 @@ class FromTastyTests extends ParallelTesting {
459450
"t4911",
460451
"t5031_2",
461452
"t5033",
462-
"t5071",
463453
"t5178",
464454
"t5240",
465455
"t530",
@@ -525,8 +515,8 @@ class FromTastyTests extends ParallelTesting {
525515
"t7694",
526516
"t7753",
527517
"t7785",
528-
"t780",
529518
"t7815",
519+
"t7853",
530520
"t7864",
531521
"t789",
532522
"t7902",
@@ -569,7 +559,6 @@ class FromTastyTests extends ParallelTesting {
569559
"typeinferNull",
570560
"unapply",
571561
"unapplyComplex",
572-
"unapplyContexts2",
573562
"unapplyGeneric",
574563
"unicode-decode",
575564
"vararg-pattern",

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,30 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
146146
case stat@Import(_, _) => stat
147147
case stat@Term() => stat
148148
}
149-
if (stats1.nonEmpty) {
149+
150+
def printBody(printSelf: Boolean) = {
150151
this += " {"
151152
indented {
153+
if (printSelf) {
154+
val Some(ValDef(name, tpt, _)) = self
155+
indented {
156+
val name1 = if (name == "_") "this" else name
157+
this += " " += name1 += ": "
158+
printTypeTree(tpt)
159+
this += " =>"
160+
}
161+
}
152162
this += lineBreak()
153163
printTrees(stats1, lineBreak())
154164
}
155165
this += lineBreak() += "}"
156166
}
167+
self match {
168+
case Some(ValDef(_, TypeTree.Singleton(_), _)) =>
169+
if (stats1.nonEmpty) printBody(printSelf = false)
170+
case Some(ValDef(_, _, _)) => printBody(printSelf = true)
171+
case _ => if (stats1.nonEmpty) printBody(printSelf = false)
172+
}
157173
this
158174

159175
case tdef @ TypeDef(name, rhs) =>

tests/pos/selftypes.decompiled

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/** Decompiled from out/posTestFromTasty/pos/selftypes/selftypes.class */
2+
object selftypes {
3+
trait A() extends java.lang.Object { self: selftypes.AB =>
4+
type AA = scala.List[this.BX]
5+
class AX()
6+
}
7+
trait B() extends java.lang.Object { self: selftypes.AB =>
8+
type BB = B.this.AA
9+
class BX()
10+
}
11+
class AB() extends selftypes.A with selftypes.B
12+
}

0 commit comments

Comments
 (0)