File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
compiler/src/dotty/tools/dotc/printing Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -128,8 +128,13 @@ object Formatting {
128128 }
129129
130130 private class ExplainingPrinter (seen : Seen )(_ctx : Context ) extends RefinedPrinter (_ctx) {
131+
132+ /** True if printer should a source module instead of its module class */
133+ private def useSourceModule (sym : Symbol ): Boolean =
134+ sym.is(ModuleClass , butNot = Package ) && sym.sourceModule.exists && ! _ctx.settings.YdebugNames .value
135+
131136 override def simpleNameString (sym : Symbol ): String =
132- if ((sym is ModuleClass ) && sym.sourceModule.exists ) simpleNameString(sym.sourceModule)
137+ if (useSourceModule (sym) ) simpleNameString(sym.sourceModule)
133138 else seen.record(super .simpleNameString(sym), sym)
134139
135140 override def ParamRefNameString (param : ParamRef ): String =
@@ -139,6 +144,11 @@ object Formatting {
139144 case tp : SkolemType => seen.record(tp.repr.toString, tp)
140145 case _ => super .toTextRef(tp)
141146 }
147+
148+ override def toText (tp : Type ): Text = tp match {
149+ case tp : TypeRef if useSourceModule(tp.symbol) => Str (" object " ) ~ super .toText(tp)
150+ case _ => super .toText(tp)
151+ }
142152 }
143153
144154 /** Create explanation for single `Recorded` type or symbol */
You can’t perform that action at this time.
0 commit comments