diff options
author | Martin Odersky <odersky@gmail.com> | 2016-08-13 13:32:17 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-08-16 17:34:42 +0200 |
commit | 71070854e4385198a9895a434a2623d313ca94dc (patch) | |
tree | 4011a544f5286f038901faa99f19b69eb1189030 /src/dotty | |
parent | 4a0858fab5547c896870d269968aff9674ab2ee6 (diff) | |
download | dotty-71070854e4385198a9895a434a2623d313ca94dc.tar.gz dotty-71070854e4385198a9895a434a2623d313ca94dc.tar.bz2 dotty-71070854e4385198a9895a434a2623d313ca94dc.zip |
Don't disambiguate aliases
Don't disambiguate in situations like
Predef.String
vs
java.lang.String
where one Symbol is an alias of another with the same name.
Also, fix reviewer comments wrt comments and unused defs.
Diffstat (limited to 'src/dotty')
-rw-r--r-- | src/dotty/tools/dotc/printing/Formatting.scala | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/dotty/tools/dotc/printing/Formatting.scala b/src/dotty/tools/dotc/printing/Formatting.scala index 8d7136839..8921c56a3 100644 --- a/src/dotty/tools/dotc/printing/Formatting.scala +++ b/src/dotty/tools/dotc/printing/Formatting.scala @@ -58,11 +58,11 @@ object Formatting { } } - /** The d string interpolator works like the i string interpolator, but marks nonsensical errors + /** The `em` string interpolator works like the `i` string interpolator, but marks nonsensical errors * using `<nonsensical>...</nonsensical>` tags. * Note: Instead of these tags, it would be nicer to return a data structure containing the message string * and a boolean indicating whether the message is sensical, but then we cannot use string operations - * like concatenation, stripMargin etc on the values returned by d"...", and in the current error + * like concatenation, stripMargin etc on the values returned by em"...", and in the current error * message composition methods, this is crucial. */ class ErrorMessageFormatter(sc: StringContext) extends StringFormatter(sc) { @@ -85,8 +85,15 @@ object Formatting { override def default(key: String) = Nil - def record(str: String, entry: Recorded): String = { - var alts = apply(str).dropWhile(entry ne _) + def record(str: String, entry: Recorded)(implicit ctx: Context): String = { + 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 + case _ => e1 + } + lazy val dealiased = followAlias(entry) + var alts = apply(str).dropWhile(alt => dealiased ne followAlias(alt)) if (alts.isEmpty) { alts = entry :: apply(str) update(str, alts) @@ -135,13 +142,6 @@ object Formatting { case param: PolyParam => s"is a type variable${addendum("constraint", ctx.typeComparer.bounds(param))}" case sym: Symbol => - val ownerStr = - if (!sym.exists) "" - else { - var owner = sym.effectiveOwner - if (owner.isLocalDummy) i" locally defined in ${owner.owner}" - else i" in $owner" - } s"is a ${ctx.printer.kindString(sym)}${sym.showExtendedLocation}${addendum("bounds", sym.info)}" } } |