blob: f8baa2275b8b2a5c17e190a6b7e0e8b07f816700 (
plain) (
tree)
|
|
import scala.reflect.macros.Context
import language.experimental.macros
object Interpolation {
implicit class TestInterpolation(c: StringContext) {
object t {
def unapply[T](x: T) = macro Macros.unapplyImpl[T]
}
}
}
object Macros {
def unapplyImpl[T: c.WeakTypeTag](c: Context)(x: c.Tree) = {
import c.universe._
q"""
new {
def isEmpty = false
def get = 2
def unapply(x: Int) = this
}.unapply($x)
"""
}
}
|