Skip to content

GeneralizingAstVisitor now triggers NamedCompilationUnitMember for all FunctionDeclarations #61224

@FMorschel

Description

@FMorschel

This recent change https://dart-review.googlesource.com/c/sdk/+/442561 broke this old change f61adaf that made FunctionDeclaration not trigger NamedCompilationUnitMember visit in GeneralizingAstVisitor.

@bwilkerson:

The more appropriate thing to have done would be to either:

  • Have a TopLevelFunctionDeclaration that wrapped a FunctionDeclaration the way a FunctionDeclarationStatement does, or
  • Use a technique other than wrapping to share the API of FunctionDeclaration between those two classes.

Having a separate TopLevelFunctionDeclaration that implements NamedCompilationUnitMember would have made the intended behavior of the visitor more clear. That hacky, and in some ways counter intuitive, check was there to cover over the mistake in the design of the ASTNode hierarchy. [... The change in f61adaf] needs to be added back in.

We should probably add some tests to make sure this doesn't regress too (although the changes I'm making towards #60321 should cover that too; they will need this fix to land first).

FYI @fshcheglov, @scheglov, @DanTup

Metadata

Metadata

Assignees

Labels

area-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions