aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/TypeComparer.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-10-10 12:31:59 +0200
committerMartin Odersky <odersky@gmail.com>2013-10-10 12:31:59 +0200
commitd13fa248d5c53b165ab4f927099d0e25303ef39a (patch)
treeebb509625a45ebb9b07b0b31430b2d460e0b2418 /src/dotty/tools/dotc/core/TypeComparer.scala
parentf703e4d9c006a119250e1b0202712fe3e09521b4 (diff)
downloaddotty-d13fa248d5c53b165ab4f927099d0e25303ef39a.tar.gz
dotty-d13fa248d5c53b165ab4f927099d0e25303ef39a.tar.bz2
dotty-d13fa248d5c53b165ab4f927099d0e25303ef39a.zip
Added disambiguation for reported messages.
Added method disambiguate which disambiguates any string-returning operation. Disambiguation is done by adding owners and qualifiers each symbol has a unique string representation.
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeComparer.scala')
-rw-r--r--src/dotty/tools/dotc/core/TypeComparer.scala11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala
index c54312e01..46eabb606 100644
--- a/src/dotty/tools/dotc/core/TypeComparer.scala
+++ b/src/dotty/tools/dotc/core/TypeComparer.scala
@@ -6,6 +6,7 @@ import Types._, Contexts._, Symbols._, Flags._, Names._
import Decorators.sourcePos
import StdNames.{nme, tpnme}
import collection.mutable
+import printing.Disambiguation.disambiguated
import util.SimpleMap
/** Provides methods to compare types.
@@ -681,7 +682,10 @@ class TypeComparer(initctx: Context) extends DotClass {
*/
private def andConflict(tp1: Type, tp2: Type): Type = {
val winner = if (isAsGood(tp2, tp1) && !isAsGood(tp1, tp2)) tp2 else tp1
- ctx.warning(s"${mergeErrorMsg(tp1, tp2)} as members of one type; keeping only ${showType(winner)}", ctx.tree.pos)
+ def msg = disambiguated { implicit ctx =>
+ s"${mergeErrorMsg(tp1, tp2)} as members of one type; keeping only ${showType(winner)}"
+ }
+ ctx.warning(msg, ctx.tree.pos)
winner
}
@@ -698,16 +702,15 @@ class TypeComparer(initctx: Context) extends DotClass {
}.toList
/** Show type, handling type types better than the default */
- private def showType(tp: Type) = tp match {
+ private def showType(tp: Type)(implicit ctx: Context) = tp match {
case ClassInfo(_, cls, _, _, _) => cls.showLocated
case bounds: TypeBounds => "type bounds" + bounds.show
case _ => tp.show
}
/** The error message kernel for a merge conflict */
- private def mergeErrorMsg(tp1: Type, tp2: Type) = {
+ private def mergeErrorMsg(tp1: Type, tp2: Type)(implicit ctx: Context) =
s"cannot merge ${showType(tp1)} with ${showType(tp2)}"
- }
/** A comparison function to pick a winner in case of a merge conflict */
private def isAsGood(tp1: Type, tp2: Type): Boolean = tp1 match {