diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2013-01-30 21:27:59 +0100 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2013-01-31 11:59:40 +0100 |
commit | 941c56918e052a1c619f35b24c6aa6c736390dc5 (patch) | |
tree | 24ce6935593baa26fe276e9ef91994bb69ef023d /src/compiler | |
parent | 2fa859e1b3eb2ac57058feaba87d96adfbac9209 (diff) | |
download | scala-941c56918e052a1c619f35b24c6aa6c736390dc5.tar.gz scala-941c56918e052a1c619f35b24c6aa6c736390dc5.tar.bz2 scala-941c56918e052a1c619f35b24c6aa6c736390dc5.zip |
SI-6812 scaladoc can opt out of expanding macros
This is a temporary change, possible only because macros currently can't
affect the global symbol table (except for the case when they will steer
inference of a method's return type).
Later on, e.g. with the addition of c.introduceTopLevel in master,
we will have to upgrade Scaladoc to allow for separate generation of
documentation, because then we'll be forced to expand macros in order to
get the whole picture of the code.
Diffstat (limited to 'src/compiler')
3 files changed, 9 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala index b820d10ddc..b2fc51c638 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala @@ -169,6 +169,7 @@ trait ScalaSettings extends AbsScalaSettings val Yrangepos = BooleanSetting ("-Yrangepos", "Use range positions for syntax trees.") val Ybuilderdebug = ChoiceSetting ("-Ybuilder-debug", "manager", "Compile using the specified build manager.", List("none", "refined", "simple"), "none") val Yreifycopypaste = BooleanSetting ("-Yreify-copypaste", "Dump the reified trees in copypasteable representation.") + val Ymacronoexpand = BooleanSetting ("-Ymacro-no-expand", "Don't expand macros. Might be useful for scaladoc and presentation compiler, but will crash anything which uses macros and gets past typer.") val Yreplsync = BooleanSetting ("-Yrepl-sync", "Do not use asynchronous code for repl startup") val Ynotnull = BooleanSetting ("-Ynotnull", "Enable (experimental and incomplete) scala.NotNull.") val YmethodInfer = BooleanSetting ("-Yinfer-argument-types", "Infer types for arguments of overriden methods.") diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala index dc367b11fd..f76f1a1a65 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala @@ -763,10 +763,14 @@ trait ContextErrors { else " of " + expanded.getClass )) - def MacroImplementationNotFoundError(expandee: Tree) = - macroExpansionError(expandee, + def MacroImplementationNotFoundError(expandee: Tree) = { + val message = "macro implementation not found: " + expandee.symbol.name + " " + - "(the most common reason for that is that you cannot use macro implementations in the same compilation run that defines them)") + "(the most common reason for that is that you cannot use macro implementations in the same compilation run that defines them)" + + (if (forScaladoc) ". When generating scaladocs for multiple projects at once, consider using -Ymacro-no-expand to disable macro expansions altogether." + else "") + macroExpansionError(expandee, message) + } } } diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala index b20a9ea626..203367c1d5 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala @@ -684,6 +684,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { * the expandee with an error marker set if there has been an error */ def macroExpand(typer: Typer, expandee: Tree, mode: Int = EXPRmode, pt: Type = WildcardType): Tree = { + if (settings.Ymacronoexpand.value) return expandee // SI-6812 val start = if (Statistics.canEnable) Statistics.startTimer(macroExpandNanos) else null if (Statistics.canEnable) Statistics.incCounter(macroExpandCount) try { |