-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Name lookup] Use decl-based name lookup more regularly #18539
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
[Name lookup] Use decl-based name lookup more regularly #18539
Conversation
@@ -2201,8 +2277,6 @@ directReferencesForTypeRepr(Evaluator &evaluator, | |||
} | |||
} | |||
|
|||
/// Retrieve the set of type declarations that are directly referenced from | |||
/// the given type. | |||
static DirectlyReferencedTypeDecls | |||
directReferencesForType(Type type) { |
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 looks like it could fit on one line
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. Will do in a follow-up
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.
It ended up in https://github.com/apple/swift/pull/18562/files
65bfccd
to
7b3fad8
Compare
@swift-ci please test |
@swift-ci please test source compatibility |
Build failed |
Build failed |
@swift-ci please smoke test |
@swift-ci please test source compatibility |
@swift-ci please smoke test |
@swift-ci please test source compatibility |
@swift-ci please test compiler performance |
1 similar comment
@swift-ci please test compiler performance |
@swift-ci please test compiler performance |
@swift-ci please smoke test |
@swift-ci please test compiler performance |
@swift-ci please smoke test |
Build comment file:Summary for master fullUnexpected test results, excluded stats for RxSwift, ChattoAdditions, ProcedureKitCloud, DatabaseKit, ReactiveSwift, ReactiveCocoa, Wordy Regressions found (see below) Debug-batchdebug-batch briefRegressed (2)
Improved (0)
Unchanged (delta < 1.0% or delta < 100.0ms) (0)
debug-batch detailedRegressed (69)
Improved (0)
Unchanged (delta < 1.0% or delta < 100.0ms) (18)
Releaserelease briefRegressed (0)
Improved (0)
Unchanged (delta < 1.0% or delta < 100.0ms) (2)
release detailedRegressed (0)
Improved (0)
Unchanged (delta < 1.0% or delta < 100.0ms) (23)
|
Within unqualified name lookup, replace uses of Type-based lookup (formed from calls to getSelfTypeInContext()) with declaration-based name lookup, so that name lookup doesn't depend directly on the type checker. The main oddity here is that we need to consider "Self: Foo" requirements within a protocol extension during name lookup, so that we will also look into "Foo". This is handled via the basic name-lookup facilities that allow us to resolve TypeReprs to declarations without going through the type checker.
This avoids a call into the lazy resolver simply to figure out which protocols a type conforms to.
This is no longer used. NFC
It’s no longer introduced anywhere. NFC
…equest. Name lookup within a protocol extension also looks into protocols and superclasses on the right-hand side of Self constraints in the where clause, e.g., "Self: Foo". Turn that function into a request to avoid infinite recursion on invalid code.
The property that we are checking for here isn’t really local to the nominal type or extension declaration, and triggers semantic queries that aren’t needed elsewhere. Remove it, because it’s not adding value.
…face types. Fixes a diagnostics regression due to the name-shadowing changes.
There is no point in threading LazyResolver parameters through this data structure; we can recover the resolver in the one place it is needed.
58a7c83
to
e21673d
Compare
@swift-ci please smoke test |
@swift-ci please test source compatibility |
@swift-ci please smoke test |
1 similar comment
@swift-ci please smoke test |
@swift-ci please test source compatibility |
Avoid the use of the type checker in much of name lookup, relying on Decl-level information (not Type-level information) instead. There are several changes here that support each other to get back to a usable state:
Type
form oflookupQualified
(where the type was usually provided bygetSelfTypeInContext()
) with the "decl" form of the method, so we don't need to resolve types to perform unqualified name lookup.With these changes, eliminate
LazyResolver::resolveExtensionForConformanceConstruction()
and some of the type-checker logic supporting it.