A longstanding shortcoming of the AST-transformation system is the
minimal guarantees provided when multiple ASTTs target the same area
of code. While comprehensive support for this seems like it would
require a redesign or at least major rework, I have a suggestion for a
small change that might get a large segment of use cases working.

I propose adding "order" directives to transforms akin to Spring's
@Ordered and @AutoConfigureBefore/After. The sole effect of these
directives would be to instruct the compiler to run identified
transformations in sorted sequence.

As a specific hands-on use case, there's been a feature request open
against Spock for 5 years to support stateful traits
(https://github.com/spockframework/spock/issues/83); the impediment is
that both Spock and traits are implemented as SEMANTIC_ANALYSIS ASTTs,
so that Spock doesn't see the trait fields with their @Shared
annotations when it runs.

Is something like this feasible, or does it conflict with existing
sequencing or traversal requirements inside the compiler processing?

Reply via email to