Add new pending test for sbt/sbt#1237

This test shows that macros that simply return their argument produce
a stack overflow during extraction of used names.

Consider a macro `foo(c: Context)(a: c.Expr[Any]) = a`. An
application of this macro such as `foo(someVal)` will lead to the
expansion `someVal`. sbt will extract the `original` tree from it,
and find `foo(someVal)`, and recurse infinitely on `someVal`.
This commit is contained in:
Martin Duhem 2014-06-14 12:37:25 +02:00
parent 23f9dc26c7
commit aef9933d87
4 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,6 @@
package macros
object Client {
val a = 1
def test = Foo.bar(a)
}

View File

@ -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
}

View File

@ -0,0 +1,2 @@
# We only want to make sure we can compile this without stack overflow
> compile

View File

@ -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
)
}