diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2013-01-19 12:28:19 +0100 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2013-05-28 10:19:19 +0200 |
commit | 10229316dbf7afa7545d8e279b5960da6ee3db7d (patch) | |
tree | cfa50a3207aa5c1b2ce17ffba0fe1413a6f0dd53 /test/files/neg/macro-invalidimpl.check | |
parent | e0bbe0af094b9055942c24fcaaa290a31415fa0a (diff) | |
download | scala-10229316dbf7afa7545d8e279b5960da6ee3db7d.tar.gz scala-10229316dbf7afa7545d8e279b5960da6ee3db7d.tar.bz2 scala-10229316dbf7afa7545d8e279b5960da6ee3db7d.zip |
refactors macro compilation
Upgrades the way that macro defs are compiled by factoring out most of
the logic in typedMacroBody and related errors in ContextErrors into an
standalone cake. This leads to tighter cohesion and better code reuse
as the cake is isolated from the rest of the compiler and is much easier
to evolve than just a method body.
Increased convenience of coding macro compilation allowed me to further
clarify the implementation of the macro engine (e.g. take a look at
Validators.scala) and to easily implement additional features, namely:
1) Parameters and return type of macro implementations can now be plain
c.Tree's instead of previously mandatory c.Expr's. This makes macros more
lightweight as there are a lot of situations when one doesn't need to
splice macro params (the only motivation to use exprs over trees). Also
as we're on the verge of having quasiquotes in trunk, there soon will be
no reason to use exprs at all, since quasiquotes can splice everything.
2) Macro implementations can now be defined in bundles, standalone cakes
built around a macro context: http://docs.scala-lang.org/overviews/macros/bundles.html.
This further reduces boilerplate by simplifying implementations complex
macros due to the fact that macro programmers no longer need to play
path-dependent games to use helpers.
Diffstat (limited to 'test/files/neg/macro-invalidimpl.check')
-rw-r--r-- | test/files/neg/macro-invalidimpl.check | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/test/files/neg/macro-invalidimpl.check b/test/files/neg/macro-invalidimpl.check index 7177a8cdee..aaf4f88fc2 100644 --- a/test/files/neg/macro-invalidimpl.check +++ b/test/files/neg/macro-invalidimpl.check @@ -1,15 +1,23 @@ -Macros_Test_2.scala:5: error: macro implementation must be in statically accessible object +Macros_Test_2.scala:5: error: macro implementation reference has wrong shape. required: +macro [<static object>].<method name>[[<type args>]] or +macro [<macro bundle>].<method name>[[<type args>]] def foo(x: Any) = macro impls.foo - ^ -Macros_Test_2.scala:10: error: macro implementation must be in statically accessible object + ^ +Macros_Test_2.scala:10: error: macro implementation reference has wrong shape. required: +macro [<static object>].<method name>[[<type args>]] or +macro [<macro bundle>].<method name>[[<type args>]] def foo(x: Any) = macro impls.foo - ^ -Macros_Test_2.scala:18: error: macro implementation must be in statically accessible object + ^ +Macros_Test_2.scala:18: error: macro implementation reference has wrong shape. required: +macro [<static object>].<method name>[[<type args>]] or +macro [<macro bundle>].<method name>[[<type args>]] def foo(x: Any) = macro Impls3.foo - ^ -Macros_Test_2.scala:22: error: macro implementation must be in statically accessible object + ^ +Macros_Test_2.scala:22: error: macro implementation reference has wrong shape. required: +macro [<static object>].<method name>[[<type args>]] or +macro [<macro bundle>].<method name>[[<type args>]] def foo(x: Any) = macro Impls4.foo - ^ + ^ Macros_Test_2.scala:26: error: ambiguous reference to overloaded definition, both method foo in object Impls5 of type (c: scala.reflect.macros.Context)(x: c.Expr[Any], y: c.Expr[Any])Nothing and method foo in object Impls5 of type (c: scala.reflect.macros.Context)(x: c.Expr[Any])Nothing @@ -27,17 +35,17 @@ Macros_Test_2.scala:31: error: macro implementation has wrong shape: found : (c: scala.reflect.macros.Context)(): c.Expr[Unit] number of parameter sections differ def foo1 = macro Impls6.fooEmpty - ^ + ^ Macros_Test_2.scala:32: error: macro implementation has wrong shape: required: (c: scala.reflect.macros.Context)(): c.Expr[Unit] found : (c: scala.reflect.macros.Context): c.Expr[Unit] number of parameter sections differ def bar1() = macro Impls6.fooNullary - ^ + ^ Macros_Test_2.scala:36: error: type arguments [String] do not conform to method foo's type parameter bounds [U <: Int] def foo = macro Impls7.foo[String] ^ Macros_Test_2.scala:53: error: macro implementation must be public def foo = macro Impls8.impl - ^ + ^ 10 errors found |