Skip to content

Commit 9ef778a

Browse files
committed
Fix error reporting for type-mismatch
1 parent 57aa22a commit 9ef778a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,15 @@ class PlainPrinter(_ctx: Context) extends Printer {
140140
case _ => Nil
141141
})
142142

143+
/** Direct references to these symbols are printed without their prefix for convenience.
144+
* They are either aliased in scala.Predef or in the scala package object, as well as `Object`
145+
*/
146+
private lazy val printWithoutPrefix: Set[Symbol] =
147+
(defn.ScalaPredefModule.termRef.typeAliasMembers
148+
++ defn.ScalaPackageObject.termRef.typeAliasMembers).map(_.info.classSymbol).toSet
149+
+ defn.ObjectClass
150+
+ defn.FromJavaObjectSymbol
151+
143152
def toTextCaptureSet(cs: CaptureSet): Text =
144153
if printDebug && ctx.settings.YccDebug.value && !cs.isConst then cs.toString
145154
else if cs == CaptureSet.Fluid then "<fluid>"
@@ -183,6 +192,9 @@ class PlainPrinter(_ctx: Context) extends Printer {
183192
case tp: TermRef if tp.denot.isOverloaded =>
184193
"<overloaded " ~ toTextRef(tp) ~ ">"
185194
case tp: TypeRef =>
195+
if (printWithoutPrefix.contains(tp.symbol))
196+
selectionString(tp)
197+
else
186198
toTextPrefixOf(tp) ~ selectionString(tp)
187199
case tp: TermParamRef =>
188200
ParamRefNameString(tp) ~ lambdaHash(tp.binder) ~ ".type"

0 commit comments

Comments
 (0)