summaryrefslogtreecommitdiff
path: root/test/files/run/macro-parse-position-malformed
diff options
context:
space:
mode:
authorDen Shabalin <den.shabalin@gmail.com>2013-09-06 18:28:44 +0200
committerDen Shabalin <den.shabalin@gmail.com>2013-09-12 12:43:23 +0200
commit95fe19545d60ae9aa79d2c8d5665c7f3b0cbdb1a (patch)
tree7848cd767ac44c0e6e5790553d29afac9439a030 /test/files/run/macro-parse-position-malformed
parent5607bd137d8a22c6933e3692a4a1626928acf67f (diff)
downloadscala-95fe19545d60ae9aa79d2c8d5665c7f3b0cbdb1a.tar.gz
scala-95fe19545d60ae9aa79d2c8d5665c7f3b0cbdb1a.tar.bz2
scala-95fe19545d60ae9aa79d2c8d5665c7f3b0cbdb1a.zip
SI-6489 parsing in macros should provide proper positions
1. macro parsing doesn't use toolbox any more but calls parser directly 2. in order for this to work parser has to be refactored to limit usage of currentUnit and rewire it into parser's local unit method which might use currentUnit for some parsers but will user proper unit for UnitParser 3. similar change has to be done to make compilation unit's reporter overridable
Diffstat (limited to 'test/files/run/macro-parse-position-malformed')
-rw-r--r--test/files/run/macro-parse-position-malformed/Impls_Macros_1.scala17
-rw-r--r--test/files/run/macro-parse-position-malformed/Test_2.scala3
2 files changed, 20 insertions, 0 deletions
diff --git a/test/files/run/macro-parse-position-malformed/Impls_Macros_1.scala b/test/files/run/macro-parse-position-malformed/Impls_Macros_1.scala
new file mode 100644
index 0000000000..2417eb6897
--- /dev/null
+++ b/test/files/run/macro-parse-position-malformed/Impls_Macros_1.scala
@@ -0,0 +1,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
+} \ No newline at end of file
diff --git a/test/files/run/macro-parse-position-malformed/Test_2.scala b/test/files/run/macro-parse-position-malformed/Test_2.scala
new file mode 100644
index 0000000000..cff569bd81
--- /dev/null
+++ b/test/files/run/macro-parse-position-malformed/Test_2.scala
@@ -0,0 +1,3 @@
+object Test extends App {
+ println(Macros.foo)
+}