From b5c4666be9b53a5d8e8d656a3aa597b3897a37c8 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Wed, 29 Jan 2014 19:06:56 +0300 Subject: SI-6931 cleans up the position API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I have finally overcome my fear of positions and got to cleaning up its public interface. Apparently it isn’t so bad, since there’s a sane core of methods (thanks to whoever wrote the comments to internal#Position): 1) Checks to distinguish offsets, opaque ranges and transparent ranges 2) Essentials that inclide start, point, end and source 3) Factories that create new positions based on existing ones It looks like methods from the 3rd group are exactly what we’ve been looking for in SI-6931, so we have nothing to add in this commit. --- test/files/neg/t6931/Macros_1.scala | 15 +++++++++++++++ test/files/neg/t6931/Test_2.scala | 4 ++++ 2 files changed, 19 insertions(+) create mode 100644 test/files/neg/t6931/Macros_1.scala create mode 100644 test/files/neg/t6931/Test_2.scala (limited to 'test/files/neg/t6931') diff --git a/test/files/neg/t6931/Macros_1.scala b/test/files/neg/t6931/Macros_1.scala new file mode 100644 index 0000000000..56da075d1f --- /dev/null +++ b/test/files/neg/t6931/Macros_1.scala @@ -0,0 +1,15 @@ +import scala.language.experimental.macros +import scala.reflect.macros.blackbox.Context + +object Macros { + implicit class Error(ctx: StringContext) { + def err(args: Any*): Unit = macro impl + } + + def impl(c: Context)(args: c.Tree*): c.Tree = { + import c.universe._ + val q"Macros.Error(scala.StringContext.apply($arg)).err()" = c.macroApplication + for (i <- 1 to 3) c.error(arg.pos.withPoint(arg.pos.point + i - 1), i.toString) + q"()" + } +} \ No newline at end of file diff --git a/test/files/neg/t6931/Test_2.scala b/test/files/neg/t6931/Test_2.scala new file mode 100644 index 0000000000..6a6f645904 --- /dev/null +++ b/test/files/neg/t6931/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + import Macros._ + err"123" +} \ No newline at end of file -- cgit v1.2.3