Skip to content

Commit 40fffc1

Browse files
committed
Fix decompilation of annotated module reference
1 parent 1ea1642 commit 40fffc1

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
@@ -654,11 +654,23 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
654654

655655
def printTypeTree(tree: TypeTree): Buffer = tree match {
656656
case TypeTree.Synthetic() =>
657-
printType(tree.tpe)
658-
tree.tpe match {
659-
case tpe @ Type.TypeRef(name, _) if name.endsWith("$") => this += ".type"
660-
case tpe => this
661-
}
657+
def printTypeAndAnnots(tpe: Type): Buffer = tpe match {
658+
case Type.AnnotatedType(tp, annot) =>
659+
printTypeAndAnnots(tp)
660+
this += " "
661+
printAnnotation(annot)
662+
case tpe @ Type.TypeRef(name, _) if name.endsWith("$") =>
663+
printType(tpe)
664+
this += ".type"
665+
case Type.SymRef(ClassDef("Null$" | "Nothing$", _, _, _, _), Type.ThisType(Type.SymRef(PackageDef("runtime", _), NoPrefix()))) =>
666+
// scala.runtime.Null$ and scala.runtime.Nothing$ are not modules, those are their actual names
667+
printType(tpe)
668+
case tpe @ Type.SymRef(ClassDef(name, _, _, _, _), _) if name.endsWith("$") =>
669+
printType(tpe)
670+
this += ".type"
671+
case tpe => printType(tpe)
672+
}
673+
printTypeAndAnnots(tree.tpe)
662674

663675
case TypeTree.TypeIdent(name) =>
664676
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)