enforce overload declaration ordering when computing the highlighted differences #1250
+472
−3
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.
Bug/issue #, if applicable: rdar://155975575
Summary
When performing difference highlighting in the experimental overloaded symbol presentation (added in #928), the "longest common subsequence" is found based on the declaration fragments of all the overloaded symbols. However, there are some situations in which the order of declarations affects the resulting sequence, specifically when there can be multiple solutions with the same length. This can lead to situations where the same content can produce different rendered output, depending on which symbol's highlighting is computed first (since the results are memoized as of #992).
This PR removes this nondeterminism by enforcing that the declarations are ordered by their display order before computing the LCS.
Dependencies
None
Testing
Reducing this problem into a unit test is difficult, because the problem may not surface in a very small framework without many repetitions. The symbol graph added for this PR's test was modified from its original output to ensure the test data matched the real-world symbols that were exhibiting the issue, and even then the issue actually failed to show up in local testing. Still, the test does effectively demonstrate the issue.
Checklist
Make sure you check off the following items. If they cannot be completed, provide a reason.
./bin/test
script and it succeeded