Skip to content

Commit

Permalink
Merge pull request #2720 from adriaanm/ticket-7487
Browse files Browse the repository at this point in the history
SI-7487 Revert "Removed -Ymacro-no-expand."
  • Loading branch information
adriaanm committed Jul 11, 2013
2 parents 7125dc3 + be39391 commit 8b41240
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
Expand Up @@ -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.")
Expand Down
22 changes: 12 additions & 10 deletions src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala
Expand Up @@ -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
Expand Down Expand Up @@ -154,4 +156,4 @@ trait StdAttachments {
* because someone has put MacroImplRefAttachment on it.
*/
def isMacroImplRef(tree: Tree): Boolean = tree.attachments.get[MacroImplRefAttachment.type].isDefined
}
}
24 changes: 24 additions & 0 deletions 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) = ()
}

0 comments on commit 8b41240

Please sign in to comment.