diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2013-01-05 00:59:13 +0300 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2013-01-09 08:10:48 +0100 |
commit | 30e2e3a78f9061ea93352427cb0ca205203041f0 (patch) | |
tree | 710fa49e0526a85bcec39a2656db7631a14d631c /src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala | |
parent | 94de3c87edf420b4d1d8b495fd7976f4b515483d (diff) | |
download | scala-30e2e3a78f9061ea93352427cb0ca205203041f0.tar.gz scala-30e2e3a78f9061ea93352427cb0ca205203041f0.tar.bz2 scala-30e2e3a78f9061ea93352427cb0ca205203041f0.zip |
generalizes macroExpand
Changes macroExpand to accommodate expansion schemes different from the
currently supported one.
As a bonus, which follows clarification of the macro expansion logic,
this refactoring fixes suppression of macro expansions, which
previously didn't work with delayed expansion.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala index df78f8a05d..2d4054e93b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala @@ -676,6 +676,10 @@ trait ContextErrors { NormalTypeError(expandee, "too many argument lists for " + fun) } + def MacroInvalidExpansionError(expandee: Tree, role: String, allowedExpansions: String) = { + issueNormalTypeError(expandee, s"macro in $role role can only expand into $allowedExpansions") + } + // same reason as for MacroBodyTypecheckException case object MacroExpansionException extends Exception with scala.util.control.ControlThrowable @@ -757,13 +761,16 @@ trait ContextErrors { macroExpansionError(expandee, template(sym.name.nameKind).format(sym.name + " " + sym.origin, forgotten)) } - def MacroExpansionIsNotExprError(expandee: Tree, expanded: Any) = + def MacroExpansionHasInvalidTypeError(expandee: Tree, expanded: Any) = { + val expected = "expr" + val isPathMismatch = expanded != null && expanded.isInstanceOf[scala.reflect.api.Exprs#Expr[_]] macroExpansionError(expandee, - "macro must return a compiler-specific expr; returned value is " + ( + s"macro must return a compiler-specific $expected; returned value is " + ( if (expanded == null) "null" - else if (expanded.isInstanceOf[Expr[_]]) " Expr, but it doesn't belong to this compiler's universe" + else if (isPathMismatch) s" $expected, but it doesn't belong to this compiler" else " of " + expanded.getClass )) + } def MacroImplementationNotFoundError(expandee: Tree) = macroExpansionError(expandee, |