aboutsummaryrefslogtreecommitdiff
path: root/tests/disabled/macro/run/macro-subpatterns/Macro_1.scala
blob: e009e411a2d7a8664688584909840daa37310d7d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import scala.reflect.macros.whitebox.Context
import language.experimental.macros

object Extractor {
  def unapply(x: Any): Any = macro unapplyImpl
  def unapplyImpl(c: Context)(x: c.Tree) = {
    import c.universe._
    import internal._
    q"""
      new {
        def isEmpty = false
        def get = ${subpatterns(x).toString}
        def unapply(x: Any) = this
      }.unapply($x)
    """
  }
}