Skip to content

Commit 70eb907

Browse files
committed
Do not print package prefix for object this references
1 parent 95ec081 commit 70eb907

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -853,10 +853,18 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
853853
printType(tp)
854854

855855
case Type.ThisType(tp) =>
856-
printType(tp)
857856
tp match {
858-
case Type.SymRef(cdef @ ClassDef(_, _, _, _, _), _) if !cdef.flags.isObject => this += ".this"
859-
case _ => this
857+
case Type.SymRef(cdef @ ClassDef(name, _, _, _, _), prefix) if !cdef.flags.isObject =>
858+
def printPrefix(prefix: TypeOrBounds): Unit = prefix match {
859+
case Type.SymRef(ClassDef(name, _, _, _, _), prefix2) =>
860+
printPrefix(prefix2)
861+
this += name += "."
862+
case _ =>
863+
}
864+
printPrefix(prefix)
865+
this += name
866+
this += ".this"
867+
case _ => printType(tp)
860868
}
861869

862870
case Type.TypeLambda(paramNames, tparams, body) =>

0 commit comments

Comments
 (0)