From ac430ac8ba554d1b976d44598400d95ce5cf3816 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Fri, 17 Aug 2012 15:49:38 +0200 Subject: cleanup for macroExpand Error reporting is moved to ContextErrors to disentangle stuff in Macros.scala. With logics and error reporting intertwined it was an awful mess. Exceptions are used for the same reason. Instead of threading failures through the code polluting it with options/ifs, I outline the success path. It worked much better for typedMacroBody, but I'm also happy with the resulting code of macroExpand. To me a major factor towards applicability of exceptions was that they are short-lived and that there might be max one error per domain, after which we unconditionally bail. --- test/pending/neg/macro-invalidusage-badbounds-b.check | 4 ++++ test/pending/neg/macro-invalidusage-badbounds-b.flags | 1 + test/pending/neg/macro-invalidusage-badbounds-b/Impls_1.scala | 5 +++++ .../neg/macro-invalidusage-badbounds-b/Macros_Test_2.scala | 8 ++++++++ 4 files changed, 18 insertions(+) create mode 100644 test/pending/neg/macro-invalidusage-badbounds-b.check create mode 100644 test/pending/neg/macro-invalidusage-badbounds-b.flags create mode 100644 test/pending/neg/macro-invalidusage-badbounds-b/Impls_1.scala create mode 100644 test/pending/neg/macro-invalidusage-badbounds-b/Macros_Test_2.scala (limited to 'test/pending') diff --git a/test/pending/neg/macro-invalidusage-badbounds-b.check b/test/pending/neg/macro-invalidusage-badbounds-b.check new file mode 100644 index 0000000000..fd0b64533e --- /dev/null +++ b/test/pending/neg/macro-invalidusage-badbounds-b.check @@ -0,0 +1,4 @@ +Macros_Test_2.scala:7: error: type arguments [Int] do not conform to macro method foo's type parameter bounds [U <: String] + foo[Int] + ^ +one error found diff --git a/test/pending/neg/macro-invalidusage-badbounds-b.flags b/test/pending/neg/macro-invalidusage-badbounds-b.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/pending/neg/macro-invalidusage-badbounds-b.flags @@ -0,0 +1 @@ +-language:experimental.macros \ No newline at end of file diff --git a/test/pending/neg/macro-invalidusage-badbounds-b/Impls_1.scala b/test/pending/neg/macro-invalidusage-badbounds-b/Impls_1.scala new file mode 100644 index 0000000000..89020de7dd --- /dev/null +++ b/test/pending/neg/macro-invalidusage-badbounds-b/Impls_1.scala @@ -0,0 +1,5 @@ +import scala.reflect.macros.{Context => Ctx} + +object Impls { + def foo[U <: String](c: Ctx) = ??? +} diff --git a/test/pending/neg/macro-invalidusage-badbounds-b/Macros_Test_2.scala b/test/pending/neg/macro-invalidusage-badbounds-b/Macros_Test_2.scala new file mode 100644 index 0000000000..3139599108 --- /dev/null +++ b/test/pending/neg/macro-invalidusage-badbounds-b/Macros_Test_2.scala @@ -0,0 +1,8 @@ +object Macros { + def foo[U <: String] = macro Impls.foo[U] +} + +object Test extends App { + import Macros._ + foo[Int] +} \ No newline at end of file -- cgit v1.2.3