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
[Type checker] Introduce requests for @objc, override, and 'dynamic' checking #17976
[Type checker] Introduce requests for @objc, override, and 'dynamic' checking #17976
Conversation
The computation of 'dynamic' was also tangled up with |
307158e
to
29b15ad
Compare
Rebased. Here goes nothing! |
@swift-ci please test |
@swift-ci please test source compatibility |
@swift-ci please test compiler performance |
@swift-ci please test |
@swift-ci please test source compatibility |
@swift-ci please test compiler performance |
Build failed |
Build comment file:Compilation-performance test failed |
Build failed |
Well, that went poorly. |
29b15ad
to
e006070
Compare
@swift-ci please test |
@swift-ci please test source compatibility |
@swift-ci please test |
@swift-ci please test source compatibility |
Build failed |
Build failed |
Nice! I believe this will also fix SR-5317 :) |
The use of getAsClassOrClassExtensionContext() obviates the need for a specific isTypeContext() check. NFC.
…ookup. Make the TypeChecker’s name-lookup routines static, so they don’t depend on the TypeCheck instance… except for one pesky place where we jump back into protocol conformance checking. This is part of teasing apart the type checker.
…nyRequest The default move constructor and move assignment operator of AnyRequest would leave the source object in an odd state that’s destructible but does not maintain the invariant that all “normal” states store a real instance. This state breaks DenseMap, which assumes that a moved-from object is still washable.
Don’t ask to compute overridden declarations that haven’t already been computed.
Introduce a new request kind to capture the computation of the set of overridden declarations of a given declaration, eliminating the stateful “setOverriddenDecls()” calls from the type checker.
The overridden declarations of accessors are computed; they don’t need to be set explicitly.
The GenericSignatureBuilder is generating a *huge* number of invocations of AssociatedTypeDecl::getOverriddenDecls(), causing contention in the request-evaluator’s core data structures and a significant slow-down in compile-time performance when the request-evaluator is handling this computation. Those data structures need to be optimized, but in the meantime, introduce a performance hack to use the cached entry without going through the request-evaluator. This will MISS dependencies and needs to go away quickly.
6b95480
to
0966cd9
Compare
@swift-ci please test |
@swift-ci please test source compatibility |
@swift-ci please test |
@swift-ci please test source compatibility |
@swift-ci please test compiler performance |
!!! Couldn't read commit file !!! |
Build failed |
Thanks @hamishknight , I'll try the example from that bug! |
TinyPtrVector is a more-space-efficient SmallVector<_, 1>. Use it.
When Objective-C interop was enabled, we were getting overrides precomputed as part of the isObjC() check. Explicitly make sure we get overrides precompiled for non-Objective-C-based platforms.
@swift-ci please test |
@swift-ci please test source compatibility |
@swift-ci please test |
@swift-ci please test source compatibility |
Build failed |
A bunch of tests that technically require Objective-C interop were not labeled as such, and worked in the absence of Objective-C interop due to bugs in the type checker.
@swift-ci please smoke test macOS |
@swift-ci please smoke test Linux |
@swift-ci please test Linux |
1 similar comment
@swift-ci please test Linux |
Introduce new type checker requests to cover three more aspects of type-checking the interface of a declaration, peeled off from
validateDecl
and mostly separated from the type checker:ValueDecl::getOverriddenDecl(s)
: determines which declaration(s) are overridden by a given declarationValueDecl::isObjC()
: determines whether the given declaration is exposed to Objective-C.ValueDecl::isDynamic()
: a replacement for directly queryingDynamicAttr
on a declaration, this determines whether a particular declaration is 'dynamic'.All of these effectively need to be done together to break down otherwise-cyclic dependencies, e.g., because
@objc
can be inherited from an override anddynamic
is dependent on@objc
(as well as being inherited).