Skip to content

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

Merged
merged 5 commits into from
Sep 24, 2019

Conversation

CodaFi
Copy link
Contributor

@CodaFi CodaFi commented Sep 23, 2019

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

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.

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
@CodaFi CodaFi requested a review from slavapestov September 23, 2019 23:52
@CodaFi
Copy link
Contributor Author

CodaFi commented Sep 23, 2019

@swift-ci please smoke test

@CodaFi CodaFi force-pushed the an-interface-to-the-interface branch from 6a23435 to 1233cdf Compare September 24, 2019 00:24
@CodaFi
Copy link
Contributor Author

CodaFi commented Sep 24, 2019

@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));
Copy link
Contributor

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>())
Copy link
Contributor

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?

@CodaFi
Copy link
Contributor Author

CodaFi commented Sep 24, 2019

@swift-ci please smoke test macOS platform

@CodaFi
Copy link
Contributor Author

CodaFi commented Sep 24, 2019

@swift-ci please test source compatibility

@CodaFi
Copy link
Contributor Author

CodaFi commented Sep 24, 2019

⛵️

@CodaFi CodaFi merged commit 3e48f71 into swiftlang:master Sep 24, 2019
@CodaFi CodaFi deleted the an-interface-to-the-interface branch September 24, 2019 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants