-
Notifications
You must be signed in to change notification settings - Fork 10.5k
GSB: Lazy requirement signature #24591
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
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 a good start. Can you rip out all the existing explicit calls to computeRequirementSignature() too?
... also, any callers of |
Computing the requirement signature created the generic params as a side effect. Making getRequirementSignature lazy means that users of the generic params must make sure they are created before use.
d0873b4
to
e25c812
Compare
Replaces the explicit call to computeRequirementSignature from validateDecl with a lazy getRequirementSignature. A side effect is that the generic params of a ProtocolDecl are no longer computed from validateDecl and must be computed lazily too.
We can rely on lazy calls to getRequirementSignature instead.
@swift-ci Please smoke test |
@swift-ci Please test source compatibility |
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.
Looks great! You can address the nitpicks in a followup.
@@ -3284,6 +3284,7 @@ void Serializer::writeDecl(const Decl *D) { | |||
rawAccessLevel, | |||
inherited); | |||
|
|||
const_cast<ProtocolDecl*>(proto)->createGenericParamsIfMissing(); | |||
writeGenericParams(proto->getGenericParams()); |
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.
In a separate PR can you try moving the createGenericParamsIfMissing() call into getGenericParams() itself?
I think the next step is to try to remove TypeChecker::DelayedRequirementSignatures. It should not be needed any more. |
@swift-ci Please smoke test |
@swift-ci Please test source compatibility |
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 great! Just the one comment about the AST dumper.
Replace most remaining uses of isRequirementSignatureComputed by isRequirementSignatureComputing which uses Evaluator::hasActiveRequest to detect if the requirements are currently being computed.
@swift-ci Please smoke test |
@swift-ci Please test source compatibility |
Make getRequirementSignature lazy for the signature to be computed only on its first use. The requirement signature is still explicitly computed on the primary files to preserve diagnostics.