-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Requestify getInterfaceType() in Name Only #27314
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
Requestify getInterfaceType() in Name Only #27314
Conversation
Make getInterfaceType() call validateDecl on behalf of its clients. In effect, this makes the interface type behave like a request. It also means that its clients no longer need to perform a number of undesirable anti-patterns in order to sidestep the bizarre API contract validateDecl has at the moment In particular, the following things are no longer necessary: - Checking for a missing interface type then validating - Validating the interface type then retrieving it - Validating the interface type then retrieving a derived value These anti-patterns will be removed in follow-up commits
@swift-ci please smoke test |
6a23435
to
1233cdf
Compare
@swift-ci please smoke test |
// fact that they can't pull an interface type out to avoid doing work. | ||
// This is a necessary evil until we can wean them off. | ||
if (auto resolver = getASTContext().getLazyResolver()) | ||
resolver->resolveDeclSignature(const_cast<ValueDecl *>(this)); |
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.
We still need the assert after this call I think.
@@ -3241,7 +3247,7 @@ Type TypeDecl::getDeclaredInterfaceType() const { | |||
selfTy, const_cast<AssociatedTypeDecl *>(ATD)); | |||
} | |||
|
|||
Type interfaceType = hasInterfaceType() ? getInterfaceType() : nullptr; | |||
Type interfaceType = getInterfaceType(); | |||
if (interfaceType.isNull() || interfaceType->is<ErrorType>()) |
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 won't be null now?
@swift-ci please smoke test macOS platform |
@swift-ci please test source compatibility |
⛵️ |
Make getInterfaceType() call validateDecl on behalf of its clients. In effect, this makes the interface type behave like a request. It also means that its clients no longer need to perform a number of undesirable anti-patterns in order to sidestep the bizarre API contract validateDecl has at the moment
In particular, the following things are no longer necessary:
This patchset is a purely mechanical translation to the new API. There are an enormous number of places that no longer/never need to retrieve the interface type. I have tried my best to mark them off, but this patch does not go out of its way to fix them because it's already big enough as it is.
There is also one remaining use of
validateDecl
for VarDecls because that triggers a ton of extra side-effects that we need to untangle first.