Please sign in to comment.
hooks for naming and synthesis in Namers.scala and Typers.scala
Interestingly enough, despite of the implementation surface being quite noticeable, it is enough to hijack just `enterSym` and typechecking of stats for packages, templates and blocks in order to enable macro annotations. That and `ensureCompanionObject`, which I couldn't abstract away so far. An architectural note: given that a hooked method is called `X`, there are two implementations of this method. `pluginsX` is defined in AnalyzerPlugins.scala and lets macro plugins customize `X`. `standardX` is defined next to `X` and provides a default implementation. Finally `X` is changed to trivially forward to `pluginsX`. Existing and future callers of `X` now can be completely oblivious of the introduced hooks, because calls to `X` will continue working and will be correctly hooked. This makes the infrastructure more robust. The only downside is that in case when a macro plugin wants to call into the default implementation, it needs to call `standardX`, because `X` will lead to a stack overflow. However, in my opinion this not a big problem, because such failures are load and clear + for every `pluginsX` we actually provide documentation that says what is its standard impl is.
- Loading branch information...
Showing with 86 additions and 54 deletions.
- +6 −1 src/compiler/scala/reflect/macros/runtime/MacroRuntimes.scala
- +1 −1 src/compiler/scala/tools/nsc/typechecker/Analyzer.scala
- +26 −24 src/compiler/scala/tools/nsc/typechecker/AnalyzerPlugins.scala
- +22 −8 src/compiler/scala/tools/nsc/typechecker/Macros.scala
- +19 −8 src/compiler/scala/tools/nsc/typechecker/Namers.scala
- +6 −6 src/compiler/scala/tools/nsc/typechecker/Typers.scala
- +1 −1 src/repl/scala/tools/nsc/interpreter/ReplGlobal.scala
- +1 −1 test/files/neg/macro-incompatible-macro-engine/Plugin_1.scala
- +1 −1 test/files/run/macroPlugins-macroArgs/Plugin_1.scala
- +2 −2 test/files/run/macroPlugins-namerHooks.scala
- +1 −1 test/files/run/macroPlugins-typedMacroBody/Plugin_1.scala
Oops, something went wrong.