summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-08-02 06:50:28 +0000
committerPaul Phillips <paulp@improving.org>2011-08-02 06:50:28 +0000
commitcf4037a46ca3aabcff8e444d6814f5a91d023d4b (patch)
tree71e124e7c12909149158b57a32cd25792178270e /src/compiler
parent39e50a12d24e6c143cd1473e579fa197e75318a2 (diff)
downloadscala-cf4037a46ca3aabcff8e444d6814f5a91d023d4b.tar.gz
scala-cf4037a46ca3aabcff8e444d6814f5a91d023d4b.tar.bz2
scala-cf4037a46ca3aabcff8e444d6814f5a91d023d4b.zip
Made error messages like "object List is not a ...
Made error messages like "object List is not a value" be a little more helpful about why that is. No review.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/reflect/internal/TypeDebugging.scala11
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala6
3 files changed, 14 insertions, 7 deletions
diff --git a/src/compiler/scala/reflect/internal/TypeDebugging.scala b/src/compiler/scala/reflect/internal/TypeDebugging.scala
index d56e2e1991..54efef8142 100644
--- a/src/compiler/scala/reflect/internal/TypeDebugging.scala
+++ b/src/compiler/scala/reflect/internal/TypeDebugging.scala
@@ -22,11 +22,14 @@ trait TypeDebugging {
}
def ptIndent(x: Any) = ("" + x).replaceAll("\\n", " ")
def ptBlock(label: String, pairs: (String, Any)*): String = {
- val width = pairs map (_._1.length) max
- val fmt = "%-" + (width + 1) + "s %s"
- val strs = pairs map { case (k, v) => fmt.format(k, to_s(v)) }
+ if (pairs.isEmpty) label + "{ }"
+ else {
+ val width = pairs map (_._1.length) max
+ val fmt = "%-" + (width + 1) + "s %s"
+ val strs = pairs map { case (k, v) => fmt.format(k, to_s(v)) }
- strs.mkString(label + " {\n ", "\n ", "\n}")
+ strs.mkString(label + " {\n ", "\n ", "\n}")
+ }
}
def ptLine(label: String, pairs: (String, Any)*): String = {
val strs = pairs map { case (k, v) => k + "=" + to_s(v) }
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index 097bbf5915..169295e5c9 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -935,7 +935,9 @@ trait Implicits {
val infoMap = new InfoMap
getParts(tp)(infoMap, new mutable.HashSet(), Set())
- printInference("[companionImplicitMap] "+tp+" = "+infoMap)
+ printInference(
+ ptBlock("companionImplicitMap " + tp, infoMap.toSeq.map({ case (k, v) => ("" + k, v.mkString(", ")) }): _*)
+ )
infoMap
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 0385cfee63..e0639cb6cf 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -558,14 +558,16 @@ trait Typers extends Modes with Adaptations {
private def stabilize(tree: Tree, pre: Type, mode: Int, pt: Type): Tree = {
if (tree.symbol.isOverloaded && !inFunMode(mode))
inferExprAlternative(tree, pt)
+
val sym = tree.symbol
+ def fail() = errorTree(tree, sym.kindString + " " + sym.fullName + " is not a value")
if (tree.tpe.isError) tree
else if ((mode & (PATTERNmode | FUNmode)) == PATTERNmode && tree.isTerm) { // (1)
if (sym.isValue) checkStable(tree)
- else errorTree(tree, sym+" is not a value")
+ else fail()
} else if ((mode & (EXPRmode | QUALmode)) == EXPRmode && !sym.isValue && !phase.erasedTypes) { // (2)
- errorTree(tree, sym+" is not a value")
+ fail()
} else {
if (sym.isStable && pre.isStable && !isByNameParamType(tree.tpe) &&
(isStableContext(tree, mode, pt) || sym.isModule && !sym.isMethod))