Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR modifies our reparse strategy for
@typeand@satisfiesassertions. Previously, we'd generate anast.AsExpressionorast.SatisfiesExpressioncontaining clones of the target expression and type, and mark all of them asast.NodeFlagsReparsed. This had the unfortunate effect of "hiding" the target expression because it would now only occur in the AST as a reparsed node. With this PR, we still generate anast.AsExpressionorast.SatisfiesExpression, but we no longer mark it as reparsed. We re-parent the target expression into the assertion node, but still clone the target type and mark it asast.NodeFlagsReparsed. So, the AST reflects a normalast.AsExpressionorast.SatisfiesExpressionwith anExpressionchild that is the original expression andTypechild that is markedast.NodeFlagsReparsed. This flag on theTypenode makes it simple to detect the transformation, should that be necessary.With this PR we have the nice property that reparsed nodes can consistently be ignored in AST walks.
The PR also contains:
ast.GetOrCreateTokenis called with a parent markedast.NodeFlagsReparsed. Tokens should never be created from reparsed nodes.addRegionOutliningSpansis modified to skip over reparsed nodes.@satisfiesassertions to be consistent with errors spans on@typeassertions.Fixes #2245.
Fixes #2289.
Fixes #2346.