-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Sema: Various TypeRefinementContext tree fixes #76621
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
Sema: Various TypeRefinementContext tree fixes #76621
Conversation
…ases. Nodes in the TypeRefinementContext tree should be introduced for enum cases, rather than enum elements, since its the cases that carry availability annotations. Previously, enum cases in source that contained more than one element would result in a malformed TRC tree that had overlapping sibling nodes for each of the elements in a case declaration.
The `TypeRefinementContextBuilder` could visit a given `VarDecl` in the AST multiple times when the `VarDecl` has a parent `PatternBindingDecl`, resulting in duplicate TRC nodes.
Previously, the root TypeRefinementContext could contain duplicate top level nodes for any source file that had its TRC built on-demand to satisfy type checking requests before that file was explicitly typechecked.
3e6e9a5
to
2f0a22c
Compare
@swift-ci please smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ASTScope has some logic that runs in asserts builds that ensures each child node is a subrange of its parents, and that children are disjoint, etc. Maybe we can try adding something similar here?
These fixes actually came out of writing a verifier for the |
Awesome! |
@swift-ci please smoke test Linux |
swiftlang#76621 caused a regression by skipping the AST nodes nested under `defer` blocks. The node associated with a `defer` block is implicit because it is a kind of closure context synthesized by the compiler. However, the nodes it contains are not implicit and so they must be visited by the `TypeRefinementContextBuilder`.
swiftlang#76621 caused a regression by skipping the AST nodes nested under `defer` blocks. The node associated with a `defer` block is implicit because it is a kind of closure context synthesized by the compiler. However, the nodes it contains are not implicit and so they must be visited by the `TypeRefinementContextBuilder`. Resolves rdar://139012152
swiftlang#76621 caused a regression by skipping the AST nodes nested under `defer` blocks. The node associated with a `defer` block is implicit because it is a kind of closure context synthesized by the compiler. However, the nodes it contains are not implicit and so they must be visited by the `TypeRefinementContextBuilder`. Resolves rdar://139012152
There were a number of ways that the tree produced by
TypeRefinementContextBuilder
could be malformed:Fortunately, because the duplicated tree content was always ordered after the canonical child, the malformed trees never resulted in incorrect query results. Building the extra nodes did waste CPU and memory, though.