mirror of https://github.com/sbt/sbt.git
Merge pull request #1408 from Duhemm/fix-again-1237
Never inspect twice the same macro application, fix (again) #1237
This commit is contained in:
commit
099ce16f8d
|
|
@ -56,12 +56,12 @@ class ExtractUsedNames[GlobalType <: CallbackGlobal](val global: GlobalType) ext
|
|||
|
||||
def handleTreeNode(node: Tree): Unit = {
|
||||
def handleMacroExpansion(original: Tree): Unit = {
|
||||
// Some macros seem to have themselves registered as original tree.
|
||||
// In this case, we only need to handle the children of the original tree,
|
||||
// because we already handled the expanded tree.
|
||||
// Some macros seem to be their own orignal tree, or appear in the children of their
|
||||
// original tree. To prevent infinite loops, we need to filter out nodes that we already
|
||||
// handled.
|
||||
// This is only relevant for Scala 2.10.4
|
||||
// See https://issues.scala-lang.org/browse/SI-8486
|
||||
if (original == node) original.children.foreach(handleTreeNode)
|
||||
else original.foreach(handleTreeNode)
|
||||
original.filter(_ ne node).foreach(handleTreeNode)
|
||||
}
|
||||
|
||||
def handleClassicTreeNode(node: Tree): Unit = node match {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
package macros
|
||||
|
||||
object Client {
|
||||
val a = 1
|
||||
def test = Foo.bar(a)
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package macros
|
||||
|
||||
import scala.language.experimental.macros
|
||||
import scala.reflect.macros.Context
|
||||
|
||||
object Foo {
|
||||
def bar(a: Any): Any = macro impl
|
||||
def impl(c: Context)(a: c.Expr[Any]): c.Expr[Any] = a
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
|
||||
object build extends Build {
|
||||
val defaultSettings = Seq(
|
||||
libraryDependencies <+= scalaVersion("org.scala-lang" % "scala-reflect" % _ ),
|
||||
incOptions := incOptions.value.withNameHashing(true)
|
||||
)
|
||||
|
||||
lazy val root = Project(
|
||||
base = file("."),
|
||||
id = "macro",
|
||||
aggregate = Seq(macroProvider, macroClient),
|
||||
settings = Defaults.defaultSettings ++ defaultSettings
|
||||
)
|
||||
|
||||
lazy val macroProvider = Project(
|
||||
base = file("macro-provider"),
|
||||
id = "macro-provider",
|
||||
settings = Defaults.defaultSettings ++ defaultSettings
|
||||
)
|
||||
|
||||
lazy val macroClient = Project(
|
||||
base = file("macro-client"),
|
||||
id = "macro-client",
|
||||
dependencies = Seq(macroProvider),
|
||||
settings = Defaults.defaultSettings ++ defaultSettings
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
# We only want to make sure we can compile this without stack overflow
|
||||
> compile
|
||||
Loading…
Reference in New Issue