-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Sema: Small ConstraintGraph cleanup #77728
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lookupNode() returned a pair but both callers only looked at the first element of the pair.
f746685
to
6536aa6
Compare
6536aa6
to
f517c47
Compare
Also, since we add a vertex immediately after introducing a new type variable, the code path to handle the case where the type variable had a parent or fixed type was actually dead.
All but two remaining call sites can be changed to just check for a non-null solverState, because we want to assert if we're inside of an active undo. The two places inside binding inference can check isUndoActive() directly.
PotentialBindings is part of ConstraintGraphNode and there's no need to store the ConstraintSystem and TypeVariableType twice. Also it doesn't need to be optional either, because we no longer need to reset and recompute bindings.
f517c47
to
60d34a4
Compare
@swift-ci Please smoke test |
@swift-ci Please test source compatibility |
xedin
reviewed
Nov 21, 2024
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.
Looks reasonable!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
We used
operator[]
to both insert and find vertices in the ConstraintGraph. Split it up into two operations to better enforce invariants.Also, when freeing a vertex, we don't have to clear it -- assuming all changes were undone correctly, then at the time we're ready to undo the creation of the vertex, it should be empty already. Just assert instead.
Finally,
ConstraintGraphNode::Bindings
doesn't need to be Optional anymore because we never reset it. Once again, it should be empty when we free the node.