diff --git a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala index 7fed5bc97f35..83e6a3b204c3 100644 --- a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala @@ -193,7 +193,7 @@ class PlainPrinter(_ctx: Context) extends Printer { "" case tp: TypeRef => if (printWithoutPrefix.contains(tp.symbol)) - toText(tp.name) + selectionString(tp) else toTextPrefixOf(tp) ~ selectionString(tp) case tp: TermParamRef => diff --git a/compiler/src/dotty/tools/dotc/reporting/Message.scala b/compiler/src/dotty/tools/dotc/reporting/Message.scala index 11d86386d630..484789a7fe45 100644 --- a/compiler/src/dotty/tools/dotc/reporting/Message.scala +++ b/compiler/src/dotty/tools/dotc/reporting/Message.scala @@ -88,7 +88,7 @@ object Message: def followAlias(e1: Recorded): Recorded = e1 match { case e1: Symbol if e1.isAliasType => val underlying = e1.typeRef.underlyingClassRef(refinementOK = false).typeSymbol - if (underlying.name == e1.name) underlying else e1 + if (underlying.name == e1.name) underlying else e1.namedType.dealias.typeSymbol case _ => e1 } val key = SeenKey(str, isType) diff --git a/tests/neg/i18678b.check b/tests/neg/i18678b.check new file mode 100644 index 000000000000..ea4a4288b36b --- /dev/null +++ b/tests/neg/i18678b.check @@ -0,0 +1,10 @@ +-- [E007] Type Mismatch Error: tests/neg/i18678b.scala:3:16 ------------------------------------------------------------ +3 |def s: String = "" // error + | ^^ + | Found: ("" : String) + | Required: StringĀ² + | + | where: String is a class in package java.lang + | StringĀ² is a class in the empty package + | + | longer explanation available when compiling with `-explain` diff --git a/tests/neg/i18678b.scala b/tests/neg/i18678b.scala new file mode 100644 index 000000000000..9f8b40eb1b8d --- /dev/null +++ b/tests/neg/i18678b.scala @@ -0,0 +1,3 @@ +class String + +def s: String = "" // error \ No newline at end of file