summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-11-26 23:53:26 +0000
committerPaul Phillips <paulp@improving.org>2010-11-26 23:53:26 +0000
commit72d12aabf35f699ef103d79f29f8f7b21286d94c (patch)
treed2010d12e1dcc9705a9c7ff3b1005e728c04cc16 /src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala
parent5be89bb3bf95f9a11773273fee5d692e4a9a7f03 (diff)
downloadscala-72d12aabf35f699ef103d79f29f8f7b21286d94c.tar.gz
scala-72d12aabf35f699ef103d79f29f8f7b21286d94c.tar.bz2
scala-72d12aabf35f699ef103d79f29f8f7b21286d94c.zip
Some work on error messages, somewhat based on ...
Some work on error messages, somewhat based on ideas in #3092. No review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala
index 081be78c8b..99c85f72f1 100644
--- a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala
@@ -145,11 +145,15 @@ trait TypeDiagnostics {
def alternativesString(tree: Tree) =
alternatives(tree) map (x => " " + methodTypeErrorString(x)) mkString ("", " <and>\n", "\n")
- def missingParameterTypeError(fun: Tree, vparam: ValDef) = {
- val suffix = if (vparam.mods.isSynthetic) " for expanded function "+fun else ""
-
- inferError(vparam.pos, "missing parameter type" + suffix)
- ErrorType
+ def missingParameterTypeMsg(fun: Tree, vparam: ValDef) = {
+ val suffix =
+ if (!vparam.mods.isSynthetic) ""
+ else " for expanded function" + (fun match {
+ case Function(_, Match(_, _)) => "\n(see SLS 8.5, \"Pattern Matching Anonymous Functions\")"
+ case _ => " " + fun
+ })
+
+ "missing parameter type" + suffix
}
def treeSymTypeMsg(tree: Tree): String = {
@@ -170,6 +174,22 @@ trait TypeDiagnostics {
else defaultMessage
}
+ def notEnoughArgumentsMsg(fun: Tree, missing: List[Symbol]): String = {
+ val suffix = {
+ if (missing.isEmpty) ""
+ else {
+ val keep = missing take 3 map (_.name)
+ ".\nUnspecified value parameter%s %s".format(
+ if (missing.tail.isEmpty) "" else "s",
+ if (missing drop 3 nonEmpty) (keep :+ "...").mkString(", ")
+ else keep.mkString("", ", ", ".")
+ )
+ }
+ }
+
+ "not enough arguments for " + treeSymTypeMsg(fun) + suffix
+ }
+
def applyErrorMsg(tree: Tree, msg: String, argtpes: List[Type], pt: Type) = {
def asParams(xs: List[Any]) = xs.mkString("(", ", ", ")")