Skip to content

Commit e6c5b18

Browse files
committed
Don't print package objects in prefixes
1 parent d77f3ea commit e6c5b18

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,16 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
105105

106106
override def toTextPrefix(tp: Type): Text = controlled {
107107
def isOmittable(sym: Symbol) =
108-
if (printDebug) false
109-
else if (homogenizedView) isEmptyPrefix(sym) // drop <root> and anonymous classes, but not scala, Predef.
108+
if printDebug then false
109+
else if homogenizedView then isEmptyPrefix(sym) // drop <root> and anonymous classes, but not scala, Predef.
110+
else if sym.isPackageObject then isOmittablePrefix(sym.owner)
110111
else isOmittablePrefix(sym)
111112
tp match {
112113
case tp: ThisType if isOmittable(tp.cls) =>
113114
""
114115
case tp @ TermRef(pre, _) =>
115116
val sym = tp.symbol
116-
if (sym.isPackageObject && !homogenizedView) toTextPrefix(pre)
117+
if sym.isPackageObject && !homogenizedView && !printDebug then toTextPrefix(pre)
117118
else if (isOmittable(sym)) ""
118119
else super.toTextPrefix(tp)
119120
case _ => super.toTextPrefix(tp)

tests/neg/i7056.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
| value idnt1 is not a member of B.
55
| An extension method was tried, but could not be fully constructed:
66
|
7-
| i7056$package.given_T1_T[T](given_PartialId_B).idnt1()
7+
| given_T1_T[T](given_PartialId_B).idnt1()

0 commit comments

Comments
 (0)