improve method specificity algorithm #22162
Merged
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 code needed some weeding and strengthening. First, I had the existing code write out a trace of all non-subtype specificity results computed during the system image build (45MB, and took so long just to parse that it prompted me to do #22161). Then I added assertions to ensure that
morespecific(a,b) => !morespecific(b, a)
during the algorithm, and otherwise tried to clean up the logic as much as I could. I tested that against the trace, fixed the cases that needed fixing, and extracted interesting cases into a new specificity test suite.This makes many changes to the specificity relation, but mostly involving disjoint types, so it does not seem to affect any code behavior, at least in the test suite. However it is very hard to know whether this will break anything.