summaryrefslogblamecommitdiff
path: root/test/files/run/t5903d/Macros_1.scala
blob: f1f8dc1fde602799fc7e8c26a2725422ccb25a06 (plain) (tree)
1
2
3
4
5
6
7
                                            




                                                      
                                                         




               
                                            











                                          
import scala.reflect.macros.whitebox.Context
import language.experimental.macros

object Interpolation {
  implicit class TestInterpolation(c: StringContext) {
    object t {
      def unapply(x: Int): Any = 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)
    """
  }
}