diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala | 30 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 17 |
2 files changed, 27 insertions, 20 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("(", ", ", ")") diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 0ead1f6eee..155883299a 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2036,11 +2036,7 @@ trait Typers { self: Analyzer => } case _ => } - error( - vparam.pos, - "missing parameter type"+ - (if (vparam.mods.isSynthetic) " for expanded function "+fun - else "")) + error(vparam.pos, missingParameterTypeMsg(fun, vparam)) ErrorType } if (!vparam.tpt.pos.isDefined) vparam.tpt setPos vparam.pos.focus @@ -2390,16 +2386,7 @@ trait Typers { self: Analyzer => if (!(context.diagnostic contains note)) context.diagnostic = note :: context.diagnostic doTypedApply(tree, if (blockIsEmpty) fun else fun1, allArgs, mode, pt) } else { - tryTupleApply.getOrElse { - val suffix = - if (missing.isEmpty) "" - else { - val missingStr = missing.take(3).map(_.name).mkString(", ") + (if (missing.length > 3) ", ..." else ".") - val sOpt = if (missing.length > 1) "s" else "" - ".\nUnspecified value parameter"+ sOpt +" "+ missingStr - } - errorTree(tree, "not enough arguments for "+treeSymTypeMsg(fun) + suffix) - } + tryTupleApply getOrElse errorTree(tree, notEnoughArgumentsMsg(fun, missing)) } } } |