blob: 6286ea2a8c44210e47764aa5f8df018a5dbb759d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
import scala.language.experimental.macros
import scala.reflect.macros._
abstract class AbstractBundle(val c: blackbox.Context) {
import c.Expr
import c.universe._
def foo: Expr[Int] = Expr[Int](q"5")
}
class ConcreteBundle(override val c: blackbox.Context) extends AbstractBundle(c) {
import c.Expr
val bar: Expr[Int] = foo
}
object InvokeBundle {
def foo: Int = macro ConcreteBundle.foo // nope
def bar: Int = macro ConcreteBundle.bar // yep
}
|