In the Scala refactoring library, I solved it using the CompilerAccess property:
trait CompilerAccess { val global: tools.nsc.Global }
Now all the other traits that need to access global
just declare CompilerAccess
as a dependency:
trait TreeTraverser { this: CompilerAccess => import global._ ... }
and then there is a class that mixes up in all of these ways and provides an instance of global:
trait SomeRefactoring extends TreeTraverser with OtherTrait with MoreTraits { val global = //wherever you get your global from }
This circuit worked for me well.
source share