It did occur to me that I could, instead, write a little utility that uses reflection to generate source code, but I fear that that's a non-starter because it's going to fall foul of type erasure.
But - is there any reason why I shouldn't write a compiler plugin that generates source code? I could have it run after the typer (so it has access to all the type information it needs) and before type erasure. Normally it would do nothing, but if switched on with a custom compiler option, it would write source code that could then be used in subsequent compilations?
Is there any reason why this is a really bad idea?
Alternatively, is there anything that's changed recently that means that generating synthetic methods in a plugin is likely to work better than it has in the past?
--
paul.butcher->msgCount++
Snetterton, Castle Combe, Cadwell Park...
Who says I have a one track mind?
http://www.paulbutcher.com/
LinkedIn: http://www.linkedin.com/in/paulbutcher
MSN: pa...@paulbutcher.com
AIM: paulrabutcher
Skype: paulrabutcher
> it would write source code that could then be used in subsequent
> compilations?
> Is there any reason why this is a really bad idea?
Not sure whether it's the best approach for the case at hand, but emitting
modified sources has proved quite useful in at least one scenario: a batch
tool to migrate sources into a new API:
http://lamp.epfl.ch/~magarcia/jdk2ikvm/
Miguel
http://lamp.epfl.ch/~magarcia/ScalaCompilerCornerReloaded/
Great - thanks for the pointer!