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