Reproduce sbt/sbt#2560

Unlike other scripted macro tests, the call site of this macro is
`Provider.tree(0)`, which does not introduce internal member reference.
Instead the macro itself calls `Bar.bar(0)`. Due to #2560, the expanded
tree is not traversed, and thus the reference to `Bar` is not caught
during incremental compilation.
This commit is contained in:
Eugene Yokota 2016-04-18 02:31:24 -04:00
parent 6b16ade94b
commit 8c819fea6d
6 changed files with 64 additions and 0 deletions

View File

@ -0,0 +1,22 @@
val defaultSettings = Seq(
scalaVersion := "2.11.8",
libraryDependencies <+= scalaVersion("org.scala-lang" % "scala-reflect" % _ )//,
//incOptions := incOptions.value.withNameHashing(true)
)
lazy val root = (project in file(".")).
aggregate(macroProvider, macroClient).
settings(
defaultSettings
)
lazy val macroProvider = (project in file("macro-provider")).
settings(
defaultSettings
)
lazy val macroClient = (project in file("macro-client")).
dependsOn(macroProvider).
settings(
defaultSettings
)

View File

@ -0,0 +1,5 @@
package example
object Bar {
def bar(x: Int, y: Int): Int = x
}

View File

@ -0,0 +1,5 @@
package example
object Bar {
def bar(x: Int): Int = x
}

View File

@ -0,0 +1,5 @@
package example
object Client {
def foo: Unit = Provider.tree(0)
}

View File

@ -0,0 +1,16 @@
package example
import scala.language.experimental.macros
import scala.reflect.macros._
object Provider {
def tree(args: Any): Any = macro treeImpl
def treeImpl(c: Context)(args: c.Expr[Any]) = {
import c.universe._
c.Expr[Any](
Apply(
Select(Ident(TermName("Bar")), TermName("bar")),
List(Literal(Constant(0))))
)
}
}

View File

@ -0,0 +1,11 @@
> compile
## Replace client-side file Bar.scala to something that should not compile
$ copy-file changes/Bar.scala macro-client/Bar.scala
## Expect failure here
-> macroClient/compile
## It should still fail after clean
> macroClient/clean
-> macroClient/compile