From be393913a822456683a57c747965f7ee80a2a537 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Wed, 10 Jul 2013 15:05:45 -0700 Subject: SI-7487 Revert "Removed -Ymacro-no-expand." This reverts commit 71fb0b83a, which itself reverted the fix for SI-6812. --- .../scala/tools/nsc/settings/ScalaSettings.scala | 1 + .../tools/nsc/typechecker/StdAttachments.scala | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) (limited to 'src') 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 +} -- cgit v1.2.3