Hi,
For the last week, we've been working on :
- Scalahost, a compiler plugin that tracks the symbols touched during the expansion of a macro
- Providing a mean to record dependencies that come from macro expansions in sbt
- Making the two work together
Would you be interested in integrating this in sbt ?
Scalahost is a compiler plugin for scalac 2.11.0. Its job is to register all the symbols that are touched during the expansion of a macro, and attach them to the expanded macro. Using this information, we can deduct the dependencies between the expanded macro and everything that has been involved in its expansion.
Scalahost adds an attachment to the expanded macro. This attachment is a Map[String, Any], so that we can extract it without using an additional library or reflection.
For instance, the problems illustrated by these scripted tests are solved using scalahost :
Unfortunately, scalahost suffers from some limitations and won't work in some cases. With some macros, scalahost will fail during the expansion. (I am sorry I don't know the macro engine well enough to be able to explain from where this limitation comes from, maybe Eugene can elaborate ?)
What has been done regarding the dependencies from macro expansions ?
Dependencies that come from macro expansions require special handling (please see this discussion). Registering them with dependencies by inheritance would make debugging sbt really complicated. Therefore, I added a new "bucket" where dependencies that come from macro expansions should be registered. The logic required to invalidate macro clients has been implemented too.
I am still modifying the existing tests so that they compile with this modification and making sure that I didn't break anything, but it looks like it's working nicely.
What is needed to make scalahost work with sbt ?
What do you think ?
Even though it is not the universal solution, scalahost can still be helpful in many cases, and using the information it provides requires very little addition in sbt. Do you think that this is worth integrating in sbt ?
What do you think of the new dependencies from macro expansions thing ? Obviously, without scalahost this is not very useful, but this will come in handy when we have a more complete support of macros in sbt.