Skip to content

Make ASTGenVisitor not conform to SyntaxTransformVisitor #68350

@ahoppen

Description

@ahoppen

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:

  1. Remove the conformance of ASTGenVisitor to SyntaxTransformVisitor.
  2. Implement a visit(Syntax) method similar to SytnaxTransformVisitor.visit(Syntax) but that only handles the node kinds that we do actually support in ASTGen
  3. Once we have Remove usages of void * in CASTBridging.h #68346, change e.g. visit(TypeAliasDeclSyntax) to return a TypeAliasDecl instead of an ASTNode.
  4. And if we are no longer tied to SyntaxTransformVisitor, we might as well rename the visit methods to generate since that’s a more descriptive name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ASTGenArea → compiler: The ASTGen module, which translates SwiftSyntax trees to the C++ ASTcompilerThe Swift compiler itselfgood first issueGood for newcomersnfcFlag: No Functional Change

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions