@GroovyASTTransformation(phase = CompilePhase.CONVERSION)
public class InheritConstructorsASTStubber
extends AbstractASTTransformation
Joint-compilation stubber for InheritConstructors. Walks the superclass's declared constructors and adds a placeholder constructor on the annotated subclass for each non-private signature not already present — mirroring the surface the full transform produces at CANONICALIZATION, but at CONVERSION so the joint-compilation stub reflects it.
The placeholder body is super(args) to ensure the generated
stub Java file compiles cleanly even when the super class has no no-arg
constructor; the full transform discards the stubber-tagged placeholder
before installing its real body.
Recursive case. If the superclass also carries
@InheritConstructors, this stubber pre-processes it (the same
idiom the full transform uses), so chains like Sub ? Mid ? Base flatten
correctly within the stubber pass.
Boundary. When the super class is in the same compilation unit
and its constructors come from another CONVERSION-phase stubber
(@TupleConstructor, @MapConstructor), visibility depends
on within-phase iteration order: super-declared-first sees those
constructors, sub-declared-first does not. The stub remains a subset of
the runtime — Java callers reaching for sub's stub get a compile error
for non-stubbed signatures rather than a stub/runtime divergence. The
full transform at CANONICALIZATION still produces the complete surface
at runtime.
| Fields inherited from class | Fields |
|---|---|
class AbstractASTTransformation |
RETENTION_CLASSNODE, sourceUnit |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public void |
visit(ASTNode[] nodes, SourceUnit source) |