mirror of https://github.com/sbt/sbt.git
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:
parent
23f9dc26c7
commit
aef9933d87
|
|
@ -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,2 @@
|
|||
# We only want to make sure we can compile this without stack overflow
|
||||
> compile
|
||||
|
|
@ -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
|
||||
)
|
||||
}
|
||||
Loading…
Reference in New Issue