-
Notifications
You must be signed in to change notification settings - Fork 441
Change visit(TokenSyntax) function of SyntaxRewriter to return TokenSyntax #981
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change visit(TokenSyntax) function of SyntaxRewriter to return TokenSyntax #981
Conversation
@swift-ci Please test |
1 similar comment
@swift-ci Please test |
swiftlang/swift-stress-tester#202 @swift-ci Please test |
c6b2712
to
01e6656
Compare
swiftlang/swift-stress-tester#202 @swift-ci Please test |
I think this is for the best, but I do wonder if we should extend it to others as well. Ie. should rewriting a function decl be able to rewrite to a statement? Or should we return a decl syntax there? |
I was wondering the same. For |
One situation that comes to mind where it's valid to replace a node with one of a different kind is at a statement level; a |
Ah. I was looking at the private implementation method rather than the public one 😅. I'd still say this applies for all the functions that currently return
I think in that case I'd be fine with requiring clients to visit the parent instead, ie. I'd rather to default to not being able to rewrite to completely bogus trees but if someone reallllyy wants to... |
There should be no reason why a
TokenSyntax
should get rewritten to a different node kind and this allow us to remove a force unwrap in the diagnostics infrastructure.