summaryrefslogtreecommitdiff
path: root/test/files/neg/t5903d/Macros_1.scala
blob: 15ff226cff5b0d4b388d25658f9d581514ebba79 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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"""
      class Match(x: Int) {
        def isEmpty = false
        def get = x
      }
      new { def unapply(x: Int) = new Match(x) }.unapply($x)
    """
  }
}