Macro Bundles

Macro bundles are a feature of Scala 2.11.x and Scala 2.12.x. Macro bundles are not supported in Scala 2.10.x. They are also not supported in macro paradise for Scala 2.10.x.

Macro bundles

In Scala 2.10.x, macro implementations are represented with functions. Once the compiler sees an application of a macro definition,
it calls the macro implementation - as simple as that. However practice shows that just functions are often not enough due to the
following reasons:

Moreover, since macro parameters are path-dependent on the macro context, special incantations are required to wire implementations and helpers together.

Macro bundles provide a solution to these problems by allowing macro implementations to be declared in classes that take
c: scala.reflect.macros.blackbox.Context or c: scala.reflect.macros.whitebox.Context as their constructor parameters, relieving macro implementations from having
to declare the context in their signatures, which simplifies modularization. Referencing macro implementations defined in bundles
works in the same way as with impls defined in objects. You specify a bundle name and then select a method from it,
providing type arguments if necessary.

Blackbox vs whitebox

Macro bundles can be used to implement both blackbox and whitebox macros. Give the macro bundle constructor parameter the type of scala.reflect.macros.blackbox.Context to define a blackbox macro and the type of scala.reflect.macros.whitebox.Context to define a whitebox macro.