mirror of https://github.com/sbt/sbt.git
Add two pending tests for sbt/sbt#1237
Add two scripted tests that illustrate a problem occurring with Scala 2.11-RC3 where some macros have themselves attached as original tree, which causes a stack overflow during dependency extraction.
This commit is contained in:
parent
6f0289f633
commit
12a799c929
|
|
@ -0,0 +1,5 @@
|
|||
package macros
|
||||
|
||||
object Client {
|
||||
Provider.printTree(Foo.str)
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package macros
|
||||
|
||||
object Foo {
|
||||
def str: String = "abc"
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
package macros
|
||||
object Foo {
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package macros
|
||||
import scala.language.experimental.macros
|
||||
import scala.reflect.macros._
|
||||
|
||||
object Provider {
|
||||
def printTree(arg: Any) = macro printTreeImpl
|
||||
def printTreeImpl(c: Context)(arg: c.Expr[Any]): c.Expr[String] = {
|
||||
val argStr = arg.tree.toString
|
||||
val literalStr = c.universe.Literal(c.universe.Constant(argStr))
|
||||
c.Expr[String](literalStr)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
> compile
|
||||
|
||||
# remove `Foo.str` which is an argument to a macro
|
||||
$ copy-file macro-client/changes/Foo.scala macro-client/Foo.scala
|
||||
|
||||
# we should recompile Foo.scala first and then fail to compile Client.scala due to missing
|
||||
# `Foo.str`
|
||||
-> macro-client/compile
|
||||
|
||||
> clean
|
||||
|
||||
-> compile
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
|
||||
object build extends Build {
|
||||
val defaultSettings = Seq(
|
||||
libraryDependencies <+= scalaVersion("org.scala-lang" % "scala-reflect" % _ ),
|
||||
incOptions := incOptions.value.withNameHashing(true),
|
||||
scalaVersion := "2.11.0-RC3"
|
||||
)
|
||||
|
||||
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,5 @@
|
|||
package macros
|
||||
|
||||
object Client {
|
||||
Provider.printTree(Provider.printTree(Foo.str))
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package macros
|
||||
|
||||
object Foo {
|
||||
def str: String = "abc"
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
package macros
|
||||
object Foo {
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package macros
|
||||
import scala.language.experimental.macros
|
||||
import scala.reflect.macros._
|
||||
|
||||
object Provider {
|
||||
def printTree(arg: Any) = macro printTreeImpl
|
||||
def printTreeImpl(c: Context)(arg: c.Expr[Any]): c.Expr[String] = {
|
||||
val argStr = arg.tree.toString
|
||||
val literalStr = c.universe.Literal(c.universe.Constant(argStr))
|
||||
c.Expr[String](literalStr)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
> compile
|
||||
|
||||
# remove `Foo.str` which is an argument to a macro
|
||||
# (this macro itself that is an argument to another macro)
|
||||
$ copy-file macro-client/changes/Foo.scala macro-client/Foo.scala
|
||||
|
||||
# we should recompile Foo.scala first and then fail to compile Client.scala due to missing
|
||||
# `Foo.str`
|
||||
-> macro-client/compile
|
||||
|
||||
> clean
|
||||
|
||||
-> compile
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
|
||||
object build extends Build {
|
||||
val defaultSettings = Seq(
|
||||
libraryDependencies <+= scalaVersion("org.scala-lang" % "scala-reflect" % _ ),
|
||||
incOptions := incOptions.value.withNameHashing(true),
|
||||
scalaVersion := "2.11.0-RC3"
|
||||
)
|
||||
|
||||
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