blob: b837ffc43bca20e6f772acfc598239e808436a1c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
import scala.reflect.macros.BlackboxContext
object Helper {
def unapplySeq[T](x: List[T]): Option[Seq[T]] = List.unapplySeq[T](x)
}
object Macros {
def impl[T: c.WeakTypeTag](c: BlackboxContext)(x: c.Expr[List[T]]) = {
c.universe.reify(Helper.unapplySeq(x.splice))
}
object UnapplyMacro {
def unapplySeq[T](x: List[T]): Option[Seq[T]] = macro impl[T]
}
}
|