summaryrefslogtreecommitdiff
path: root/test/files/run/macro-parse-position-malformed/Impls_Macros_1.scala
blob: 2417eb6897ae262442861a290b28f10476eb1957 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import scala.language.experimental.macros
import scala.reflect.macros.{Context => Ctx, ParseException}

object Macros {
  def impl(c: Ctx)() = {
    import c.universe._
    val out = try {
      c.parse("foo(bar")
      "didn't fail"
    } catch {
      case e: ParseException =>
        s"failed with '${e.pos}' position and '${e.msg}' message"
    }
    c.Expr[String](Literal(Constant(out)))
  }
  def foo(): String = macro impl
}