summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2013-12-06 21:32:52 +0100
committerEugene Burmako <xeno.by@gmail.com>2013-12-06 21:32:52 +0100
commit3faa2eedd8b9f58f29a5aeed710ffb91ec0f860b (patch)
tree70b91d4326fde0c17a3a561f541edd465eac7224 /src/compiler
parent7e996c1b05902df0144709a37d9149252885495c (diff)
downloadscala-3faa2eedd8b9f58f29a5aeed710ffb91ec0f860b.tar.gz
scala-3faa2eedd8b9f58f29a5aeed710ffb91ec0f860b.tar.bz2
scala-3faa2eedd8b9f58f29a5aeed710ffb91ec0f860b.zip
[nomaster] better error messages for various macro definition errors
backport of 1d3ec4e708154ec05554f540d7d68ed55dc12426
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
index 5d6d094b44..a7b0e47214 100644
--- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
@@ -1294,7 +1294,7 @@ trait ContextErrors {
private def compatibilityError(message: String) =
implRefError(
- "macro implementation has wrong shape:"+
+ "macro implementation has incompatible shape:"+
"\n required: " + showMeth(rparamss, rret, abbreviate = true) +
"\n found : " + showMeth(aparamss, aret, abbreviate = false) +
"\n" + message)
@@ -1328,7 +1328,11 @@ trait ContextErrors {
def MacroImplOverloadedError() = implRefError("macro implementation cannot be overloaded")
- def MacroImplWrongNumberOfTypeArgumentsError(macroImplRef: Tree) = implRefError(typer.TyperErrorGen.TypedApplyWrongNumberOfTpeParametersErrorMessage(macroImplRef))
+ def MacroImplWrongNumberOfTypeArgumentsError(macroImplRef: Tree) = {
+ val MacroImplReference(owner, meth, targs) = macroImplRef
+ val diagnostic = if (meth.typeParams.length > targs.length) "has too few type arguments" else "has too many arguments"
+ implRefError(s"macro implementation reference $diagnostic for " + treeSymTypeMsg(macroImplRef))
+ }
def MacroImplNotStaticError() = implRefError("macro implementation must be in statically accessible object")
@@ -1336,7 +1340,7 @@ trait ContextErrors {
// aXXX (e.g. aparams) => characteristics of the macro impl ("a" stands for "actual")
// rXXX (e.g. rparams) => characteristics of a reference macro impl signature synthesized from the macro def ("r" stands for "reference")
- def MacroImplNonTagImplicitParameters(params: List[Symbol]) = compatibilityError("macro implementations cannot have implicit parameters other than WeakTypeTag evidences")
+ def MacroImplNonTagImplicitParameters(params: List[Symbol]) = implRefError("macro implementations cannot have implicit parameters other than WeakTypeTag evidences")
def MacroImplParamssMismatchError() = compatibilityError("number of parameter sections differ")