-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[NameLookup ] UnqualifiedLookup refactoring #22578
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
@swift-ci please test os x platform |
Build failed |
@swift-ci please smoke test os x platform |
1 similar comment
@swift-ci please smoke test os x platform |
@swift-ci please test os x platform |
Build failed |
@swift-ci please smoke test os x platform |
4 similar comments
@swift-ci please smoke test os x platform |
@swift-ci please smoke test os x platform |
@swift-ci please smoke test os x platform |
@swift-ci please smoke test os x platform |
d52f8b6
to
fef5b50
Compare
@swift-ci please smoke test os x platform |
@swift-ci please smoke test os x platform |
@swift-ci please test os x platform |
@swift-ci please test source compatibility |
@swift-ci please ASAN test |
@swift-ci please test compiler performance |
@swift-ci please smoke test compiler performance |
@swift-ci please smoke test os x platform |
@swift-ci please smoke test os x platform |
Summary for master smoketestUnexpected test results, excluded stats for ReactiveCocoa No regressions above thresholds Debugdebug briefRegressed (0)
Improved (0)
Unchanged (delta < 1.0% or delta < 100.0ms) (3)
debug detailedRegressed (0)
Improved (0)
Unchanged (delta < 1.0% or delta < 100.0ms) (23)
Releaserelease briefRegressed (0)
Improved (0)
Unchanged (delta < 1.0% or delta < 100.0ms) (3)
release detailedRegressed (0)
Improved (0)
Unchanged (delta < 1.0% or delta < 100.0ms) (23)
|
@swift-ci please clean smoke test os x platform |
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.
Very few comments this time around; the new structure is far clearer, and should make it easier to improve this part of the code base in the future.
lib/AST/UnqualifiedLookup.cpp
Outdated
private: | ||
|
||
// TODO: better name than DC | ||
struct DCAndResolvedIsCascadingUse { |
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.
ContextAndResolvedCascadingUse
?
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.
Sure! Have made that change.
lib/AST/UnqualifiedLookup.cpp
Outdated
DeclContext *const dynamicContext; | ||
/// Types are formally members of the metatype, i.e. the static type of the | ||
/// activation record. | ||
// DOUG: can you help clarify the above comments? |
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.
I think they're accurate.
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.
OK, thanks!
lib/AST/UnqualifiedLookup.cpp
Outdated
/// But in addition, self could conform to any number of protocols. | ||
/// For example, when there's a protocol extension, e.g. extension P where | ||
/// self: P2, self also conforms to P2 so P2 must be searched. | ||
class ResultFinderForSelfsConformances { |
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.
Rather than "for Self's conformances", maybe we want to say this is for "for type contexts"? That's the general case; that we're collecting constraints on Self
to find these types is more of an implementation detail.
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.
Good thought. As it is, I believe that the structure is self-specific because the constructer calls findNominalTypesThatSelfMustConformTo
which in turn calls dc->getSelfNominalTypeDecl()
. But yes, it could certainly be parameterized and generalized, by for example passing in a NominalTypeDecl
in to the constructor. Would there be a use for such a generalized facility?
SourceLoc Loc, | ||
Options options, | ||
UnqualifiedLookup &lookupToBeCreated) | ||
: |
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.
This formatting where the member initializations are at column zero makes my cringe ;)
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.
Oops! Yes, I wanted one per line, but not at zero. I can move them to col 2, but is there a better way? Clang-format wants to pack >1 per line...
Thanks, @DougGregor for your review and for the encouragement. |
@swift-ci please smoke test |
@swift-ci please test compiler performance |
// When a generic has the same name as a member, Swift prioritizes the generic | ||
// because the member could still be named by qualifying it. But there is no | ||
// corresponding way to qualify a generic parameter. | ||
// So, look for genrics first. |
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.
Minor typo "genrics"
@swift-ci please smoke test and merge |
@swift-ci please smoke test |
@DougGregor Thanks for spotting the typo! Have started another PR to fix it. |
Refactor UnqualifiedLookup. All the work was done in the constructor. This PR adds an UnqualifiedLookupFactory, and refactors all the code in the constructor for the sake of clarity. It should be no functional change. It retains the legacy code for now, and performs a cross-check when assertions are enabled.