liufengyun / gestalt

gestalt : portable and solid macros for Scala
https://github.com/scalacenter/macros
31 stars 3 forks source link

Split toolbox to StructToolbox and TypeToolbox #28

Closed liufengyun closed 7 years ago

liufengyun commented 7 years ago

Now the split is done and the test set pass -- except one cheat to change the definition of one annotation macro in order for it to compile. I think it's possible to do better without the cheat, I'll improve tomorrow.

Modifiers are refactored completely, they are no longer trees. The usage of modifiers for macro writers will be much simpler.

Review @valdisxp1 .

liufengyun commented 7 years ago

Now the cheat removed, and we produce a nice message if the macro writers trying to match modifiers exactly (match modifiers by a variable is OK):

[error] 8 |    val q"object $name { ..$stats }" = defn
[error]   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error]   |        Match modifiers in syntax is problematic and not supported.

I assume under no scenarios any sane macros should match modifiers exactly -- it's totally wrong, I can see no justification for doing that. Thus, if they do, we produce an error and it's good to prevent bad macros.