Skip to content

Commit 91d33f0

Browse files
committed
Do not print ".type" for singleton literal types
1 parent b86b76f commit 91d33f0

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,10 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
622622

623623
case TypeTree.Singleton(ref) =>
624624
printTree(ref)
625-
this += ".type"
625+
ref match {
626+
case Term.Literal(_) => this
627+
case _ => this += ".type"
628+
}
626629

627630
case TypeTree.Refined(tpt, refinements) =>
628631
printTypeTree(tpt)

tests/pos/simpleSingleton.decompiled

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ class Foo() {
44
val a: x.type = x
55
val b: Foo.type = Foo
66
val c: Foo.Bar.type = Foo.Bar
7+
val d: 1 = 1
8+
val e: "abc" = "abc"
79
()
810
}
911
}

tests/pos/simpleSingleton.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ class Foo {
33
val a: x.type = x
44
val b: Foo.type = Foo
55
val c: Foo.Bar.type = Foo.Bar
6+
val d: 1 = 1
7+
val e: "abc" = "abc"
68
}
79
}
810

0 commit comments

Comments
 (0)