mirror of https://github.com/sbt/sbt.git
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:
parent
6b16ade94b
commit
8c819fea6d
|
|
@ -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
|
||||
)
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package example
|
||||
|
||||
object Bar {
|
||||
def bar(x: Int, y: Int): Int = x
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package example
|
||||
|
||||
object Bar {
|
||||
def bar(x: Int): Int = x
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package example
|
||||
|
||||
object Client {
|
||||
def foo: Unit = Provider.tree(0)
|
||||
}
|
||||
|
|
@ -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))))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
Loading…
Reference in New Issue