Skip to content

Commit 9f857ad

Browse files
committed
Fix decompilation of annotated module reference
1 parent 31045b3 commit 9f857ad

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ class FromTastyTests extends ParallelTesting {
3838
"t3612.scala",
3939
),
4040
recompilationBlacklist = Set(
41-
"simpleCaseObject",
4241
"annot-bootstrap.scala",
4342
)
4443
).checkCompile()

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

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -676,11 +676,23 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
676676

677677
def printTypeTree(tree: TypeTree): Buffer = tree match {
678678
case TypeTree.Synthetic() =>
679-
printType(tree.tpe)
680-
tree.tpe match {
681-
case tpe @ Type.TypeRef(name, _) if name.endsWith("$") => this += ".type"
682-
case tpe => this
683-
}
679+
def printTypeAndAnnots(tpe: Type): Buffer = tpe match {
680+
case Type.AnnotatedType(tp, annot) =>
681+
printTypeAndAnnots(tp)
682+
this += " "
683+
printAnnotation(annot)
684+
case tpe @ Type.TypeRef(name, _) if name.endsWith("$") =>
685+
printType(tpe)
686+
this += ".type"
687+
case Type.SymRef(ClassDef("Null$" | "Nothing$", _, _, _, _), Type.ThisType(Type.SymRef(PackageDef("runtime", _), NoPrefix()))) =>
688+
// scala.runtime.Null$ and scala.runtime.Nothing$ are not modules, those are their actual names
689+
printType(tpe)
690+
case tpe @ Type.SymRef(ClassDef(name, _, _, _, _), _) if name.endsWith("$") =>
691+
printType(tpe)
692+
this += ".type"
693+
case tpe => printType(tpe)
694+
}
695+
printTypeAndAnnots(tree.tpe)
684696

685697
case TypeTree.TypeIdent(name) =>
686698
printType(tree.tpe)

tests/pos/simpleCaseObject.decompiled

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package foo {
33
case object Foo {
44
override def hashCode(): scala.Int = 1045991777
55
override def toString(): java.lang.String = "Foo"
6-
override def canEqual(that: scala.Any): scala.Boolean = that.isInstanceOf[foo.Foo @scala.unchecked()]
6+
override def canEqual(that: scala.Any): scala.Boolean = that.isInstanceOf[foo.Foo.type @scala.unchecked()]
77
override def productArity: scala.Int = 0
88
override def productPrefix: java.lang.String = "Foo"
99
override def productElement(n: scala.Int): scala.Any = n match {

0 commit comments

Comments
 (0)