-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[ConstraintSystem] Improve the "transitive conformance" heuristic and remove early conformance checking from DisjunctionStep::shouldSkip
#38700
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
Conversation
…ecking implicit conversions if the type does not conform and the current score is equal to the best score. Implicit conversions will always increase the score, so if the current score is equal to the best score and an implicit conversion is needed to satisfy a conformance requirement, the solver would end up pruning that path later on anyway. It's better to fail early.
DisjunctionStep::shouldSkip. This heuristic is generalized via the transitive conformance constraint.
@swift-ci please test source compatibility |
@swift-ci please test compiler performance |
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.
Awesome!
@swift-ci please smoke test |
@swift-ci please test Windows platform |
Not sure what's going on with the debug performance results, but an increase in constraint scopes in the release results is expected. With the old code, overloads were pruned in |
The "transitive conformance" constraint is a generalization of the early conformance checking in
DisjunctionStep::shouldSkip
. The code inDisjunctionStep
ignored the potential for implicit conversions if the best score is equal to the current score, because if the current path needs an implicit conversion to satisfy a conformance requirement, that score would be worse anyway. We can use this assumption when simplifying a transitive conformance constraint, and remove the conformance checking fromDisjunctionStep
.