Skip to content

Commit 6b8d0ba

Browse files
committed
Fix printing super
1 parent 90904e8 commit 6b8d0ba

File tree

3 files changed

+38
-4
lines changed

3 files changed

+38
-4
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,13 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
316316
this += "]"
317317
}
318318

319-
case Term.Super(qual, tptOpt) =>
320-
printTree(qual)
321-
this += ".super"
322-
// TODO use tptOpt?
319+
case Term.Super(qual, idOpt) =>
320+
this += "super"
321+
for (id <- idOpt) {
322+
val Id(name) = id
323+
this += "[" += name += "]"
324+
}
325+
this
323326

324327
case Term.Typed(term, tpt) =>
325328
tpt.tpe match {

tests/pos/simpleSuper.decompiled

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/** Decompiled from out/posTestFromTasty/pos/simpleSuper/foo/A.class */
2+
package foo {
3+
class A() {
4+
def foo: scala.Int = 1
5+
}
6+
}
7+
/** Decompiled from out/posTestFromTasty/pos/simpleSuper/foo/B.class */
8+
package foo {
9+
trait B() extends java.lang.Object {
10+
def foo: scala.Int = 2
11+
}
12+
}
13+
/** Decompiled from out/posTestFromTasty/pos/simpleSuper/foo/C.class */
14+
package foo {
15+
class C() extends foo.A() with foo.B {
16+
override def foo: scala.Int = super.foo.+(super[B].foo)
17+
}
18+
}

tests/pos/simpleSuper.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package foo
2+
3+
class A {
4+
def foo: Int = 1
5+
}
6+
7+
trait B {
8+
def foo: Int = 2
9+
}
10+
11+
class C extends A with B {
12+
override def foo: Int = super.foo + super[B].foo
13+
}

0 commit comments

Comments
 (0)