summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2009-06-30 18:27:18 +0000
committerPaul Phillips <paulp@improving.org>2009-06-30 18:27:18 +0000
commitb640b4c70f3dfbc2db48d81f5d853227e3a0c732 (patch)
treebca56b977361c33d2709a4975e4f52d12f2da51b /src
parentd14b4a117e477505afa4b2417133d3b8325ba4d3 (diff)
downloadscala-b640b4c70f3dfbc2db48d81f5d853227e3a0c732.tar.gz
scala-b640b4c70f3dfbc2db48d81f5d853227e3a0c732.tar.bz2
scala-b640b4c70f3dfbc2db48d81f5d853227e3a0c732.zip
Enhanced error message when a type error is bec...
Enhanced error message when a type error is because of identically named classes, one in scala.* and one not.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
index 2157833493..7565b20c56 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -292,7 +292,10 @@ trait Infer {
withDisambiguation(tp1, tp2) { global.explainTypes(tp1, tp2) }
/** If types `tp1' `tp2' contain different type variables with same name
- * differentiate the names by including owner information
+ * differentiate the names by including owner information. Also, if the
+ * type error is because of a conflict between two identically named
+ * classes and one is in package scala, fully qualify the name so one
+ * need not deduce why "java.util.Iterator" and "Iterator" don't match.
*/
private def withDisambiguation[T](tp1: Type, tp2: Type)(op: => T): T = {
@@ -306,13 +309,22 @@ trait Infer {
for {
t1 @ TypeRef(_, sym1, _) <- tp1
t2 @ TypeRef(_, sym2, _) <- tp2
- if sym1 != sym2 && t1.toString == t2.toString
+ if sym1 != sym2
} {
- val name = sym1.name
- explainName(sym1)
- explainName(sym2)
- if (sym1.owner == sym2.owner) sym2.name = newTypeName("(some other)"+sym2.name)
- patches += ((sym1, sym2, name))
+ if (t1.toString == t2.toString) { // type variable collisions
+ val name = sym1.name
+ explainName(sym1)
+ explainName(sym2)
+ if (sym1.owner == sym2.owner) sym2.name = newTypeName("(some other)"+sym2.name)
+ patches += ((sym1, sym2, name))
+ }
+ else if (sym1.name == sym2.name) { // symbol name collisions where one is in scala._
+ val name = sym1.name
+ def scalaQualify(s: Symbol) =
+ if (s.owner.isScalaPackageClass) s.name = newTypeName("scala." + s.name)
+ List(sym1, sym2) foreach scalaQualify
+ patches += ((sym1, sym2, name))
+ }
}
val result = op