-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Diagnostics] Correctly identify location of requirement failure #26677
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
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
@swift-ci please test source compatibility |
@swift-ci please smoke test compiler performance |
hborla
approved these changes
Aug 16, 2019
@swift-ci please smoke test |
DougGregor
approved these changes
Aug 16, 2019
…e variables This comes up, for example, when `Self` type parameter is bound to its argument in a member reference, both argument and parameter can refer to exact same requirements, that have to be deduplicated otherwise they are just going to get "fixed" N times, which complicates diagnostics.
… path Such tracking makes it easier to ignore already "fixed" requirements which have been recorded in the constraint system multiple times e.g. a call to initializer would open both base type and initializer method which have shared (if not the same) requirements.
Previously in situations like: ```swift protocol P {} struct S<T: P> { var value: T } _ = S(value: 42) ``` Diagnostic has reported a problem as related to "reference" to `init` but the failing generic type requirement belongs to `S`, so a better diagnostic in such case should mention `generic struct S`.
Looks like this is not really needed since fixed requirements cache can handle such de-duplication.
c15b8df
to
df47d1b
Compare
@swift-ci please smoke test |
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.
Previously in situations like:
Diagnostic has reported a problem as related to "reference" to
init
but the failing generic type requirement belongs to
S
, so abetter diagnostic in such case should mention
generic struct S
.In order to do that we need to first de-duplicate generic type requirement
checking since constraint system would record generic parameter multiple
times: 1. While resolving
S
and 2. When determining a type of constructor member.And afterwards add special logic to
RequirementFailure
to determine wheregeneric signature came from.