-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
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
.
The more appropriate thing to have done would be to either:
- Have a
TopLevelFunctionDeclaration
that wrapped aFunctionDeclaration
the way aFunctionDeclarationStatement
does, or- Use a technique other than wrapping to share the API of
FunctionDeclaration
between those two classes.Having a separate
TopLevelFunctionDeclaration
that implementsNamedCompilationUnitMember
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