-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix precedencegroup and operator decl lookup #31506
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
This comment has been minimized.
This comment has been minimized.
1ce05f4
to
8dd5f00
Compare
@swift-ci please test compiler performance |
8dd5f00
to
a551017
Compare
Ping @CodaFi @slavapestov |
CodaFi
reviewed
May 18, 2020
CodaFi
reviewed
May 18, 2020
CodaFi
reviewed
May 18, 2020
CodaFi
approved these changes
May 18, 2020
Add overloads of `removeShadowedDecls` that deal with operator and precedencegroup decls, and template the existing shadowing logic such that it can process them.
For now disabled by default, but once we get a new language mode, we should flip it on by default.
We don't need to look at re-exports when resolving cross references. Luckily the old lookup logic didn't, but the new logic will. Therefore switch it over to calling the appropriate request for a direct operator lookup. In addition, return a deserialization error instead of silently returning nullptr if the lookup fails.
Re-implement operator and precedencegroup decl lookup to use `namelookup::getAllImports` and existing decl shadowing logic. This allows us to find operator decls through `@_exported` imports, prefer operator decls defined in the same module over imported decls, and fixes a couple of other subtle issues. Because this new implementation is technically source breaking, as we can find multiple results where we used to only find one result, it's placed behind the new Frontend flag `-enable-new-operator-lookup` (with the aim of enabling it by default when we get a new language mode). However the new logic will always be used if the result is unambiguous. This means that e.g `@_exported` operators will be instantly available as long as there's only one candidate. If multiple candidates are found, we fall back to the old logic. Resolves SR-12132. Resolves rdar://59198796.
Previously we permitted operator redeclarations across files as the user could shadow imported operator decls on a per-file basis, and we would prefer an imported operator decl over one in another file. However with the new operator lookup implementation, operators in the current module always shadow imported decls. As such, we should start diagnosing cross-file redeclarations when the new lookup logic is enabled. Resolves rdar://48731166
a551017
to
e7cb6bb
Compare
@swift-ci please test |
@swift-ci please test source compatibility |
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.
Re-implement operator and
precedencegroup
decl lookup to usenamelookup::getAllImports
and existing decl shadowing logic. This allows us to find operator decls through@_exported
imports, prefer operator decls defined in the same module over imported decls, and fixes a couple of other subtle issues.Because this new implementation is technically source breaking, as we can find multiple results where we used to only find one result, it's placed behind a Frontend staging flag
-enable-new-operator-lookup
(with the aim of enabling it by default when we get a new language mode).However the new logic will always be used if the result is unambiguous. This means that e.g
@_exported
operators will be instantly available as long as there's only one candidate. If multiple candidates are found, we fall back to the old logic.Resolves SR-12132.
Resolves rdar://48731166 & rdar://59198796.