Description
The conformance of ASTGenVisitor
to SyntaxTransformVisitor
is holding us back at the moment because all visit
methods need to return an ASTNode
, which looses type information. The only thing that we get from SyntaxTransformVisitor
is the dispatch to a node-specific visit
method, which is actually also harmful because we fatalError
in case we haven’t implemented the AST generation for that node yet.
What we should do instead is:
- Remove the conformance of
ASTGenVisitor
toSyntaxTransformVisitor
. - Implement a
visit(Syntax)
method similar toSytnaxTransformVisitor.visit(Syntax)
but that only handles the node kinds that we do actually support inASTGen
- Once we have Remove usages of
void *
in CASTBridging.h #68346, change e.g.visit(TypeAliasDeclSyntax)
to return aTypeAliasDecl
instead of anASTNode
. - And if we are no longer tied to
SyntaxTransformVisitor
, we might as well rename thevisit
methods togenerate
since that’s a more descriptive name.