summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2013-07-10 17:15:54 -0700
committerAdriaan Moors <adriaan.moors@typesafe.com>2013-07-10 17:15:54 -0700
commit8b41240f3d532c470112d7bf1f409badac4d56aa (patch)
tree7e071c8f0270d1a115f6eb2177674e260efb5651
parent7125dc3e2c8e996f956bba08201c24e458391c12 (diff)
parentbe393913a822456683a57c747965f7ee80a2a537 (diff)
downloadscala-8b41240f3d532c470112d7bf1f409badac4d56aa.tar.gz
scala-8b41240f3d532c470112d7bf1f409badac4d56aa.tar.bz2
scala-8b41240f3d532c470112d7bf1f409badac4d56aa.zip
Merge pull request #2720 from adriaanm/ticket-7487v2.11.0-M4
SI-7487 Revert "Removed -Ymacro-no-expand."
-rw-r--r--src/compiler/scala/tools/nsc/settings/ScalaSettings.scala1
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala22
-rw-r--r--test/scaladoc/run/SI-6812.scala24
3 files changed, 37 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
index 993f735c72..32f0571e83 100644
--- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
+++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
@@ -166,6 +166,7 @@ trait ScalaSettings extends AbsScalaSettings
val Yrangepos = BooleanSetting ("-Yrangepos", "Use range positions for syntax trees.")
val Ymemberpos = StringSetting ("-Yshow-member-pos", "output style", "Show start and end positions of members", "") withPostSetHook (_ => Yrangepos.value = true)
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 Yreploutdir = StringSetting ("-Yrepl-outdir", "path", "Write repl-generated classfiles to given output directory (use \"\" to generate a temporary dir)" , "")
val YmethodInfer = BooleanSetting ("-Yinfer-argument-types", "Infer types for arguments of overriden methods.")
diff --git a/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala b/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala
index c616ded704..bbd51b5564 100644
--- a/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala
@@ -100,15 +100,17 @@ trait StdAttachments {
/** Determines whether a tree should not be expanded, because someone has put SuppressMacroExpansionAttachment on it or one of its children.
*/
def isMacroExpansionSuppressed(tree: Tree): Boolean =
- if (tree.attachments.get[SuppressMacroExpansionAttachment.type].isDefined) true
- else tree match {
- // we have to account for the fact that during typechecking an expandee might become wrapped,
- // i.e. surrounded by an inferred implicit argument application or by an inferred type argument application.
- // in that case the expandee itself will no longer be suppressed and we need to look at the core
- case Apply(fn, _) => isMacroExpansionSuppressed(fn)
- case TypeApply(fn, _) => isMacroExpansionSuppressed(fn)
- case _ => false
- }
+ ( settings.Ymacronoexpand.value // SI-6812
+ || tree.attachments.get[SuppressMacroExpansionAttachment.type].isDefined
+ || (tree match {
+ // we have to account for the fact that during typechecking an expandee might become wrapped,
+ // i.e. surrounded by an inferred implicit argument application or by an inferred type argument application.
+ // in that case the expandee itself will no longer be suppressed and we need to look at the core
+ case Apply(fn, _) => isMacroExpansionSuppressed(fn)
+ case TypeApply(fn, _) => isMacroExpansionSuppressed(fn)
+ case _ => false
+ })
+ )
/** After being synthesized by the parser, primary constructors aren't fully baked yet.
* A call to super in such constructors is just a fill-me-in-later dummy resolved later
@@ -154,4 +156,4 @@ trait StdAttachments {
* because someone has put MacroImplRefAttachment on it.
*/
def isMacroImplRef(tree: Tree): Boolean = tree.attachments.get[MacroImplRefAttachment.type].isDefined
-} \ No newline at end of file
+}
diff --git a/test/scaladoc/run/SI-6812.scala b/test/scaladoc/run/SI-6812.scala
new file mode 100644
index 0000000000..fbd9588ede
--- /dev/null
+++ b/test/scaladoc/run/SI-6812.scala
@@ -0,0 +1,24 @@
+import scala.tools.nsc.doc.model._
+import scala.tools.partest.ScaladocModelTest
+import language._
+
+object Test extends ScaladocModelTest {
+
+ override def code = """
+ import scala.reflect.macros.Context
+ import language.experimental.macros
+
+ object Macros {
+ def impl(c: Context) = c.literalUnit
+ def foo = macro impl
+ }
+
+ class C {
+ def bar = Macros.foo
+ }
+ """
+
+ def scaladocSettings = ""
+ override def extraSettings = super.extraSettings + " -Ymacro-no-expand"
+ def testModel(root: Package) = ()
+}