Define InterfaceTypeRequest

The moment you've all been waiting for...

Define InterfaceTypeRequest and use it to, well, compute the interface
type.  This naturally widens the few cycles that we pick up with the
request evaluator.

There is still a lot of work to get done here, mostly around scaling
back all of the ad-hoc circularity checks around the interface type
computation.  It would also be great to improve the circularity
diagnostics.
This commit is contained in:
Robert Widmann
2019-10-16 13:16:58 -07:00
parent eabce73915
commit 464aab67ec
8 changed files with 128 additions and 76 deletions

View File

@@ -2467,6 +2467,7 @@ class ValueDecl : public Decl {
friend class IsFinalRequest;
friend class IsDynamicRequest;
friend class IsImplicitlyUnwrappedOptionalRequest;
friend class InterfaceTypeRequest;
friend class Decl;
SourceLoc getLocFromSource() const { return NameLoc; }
protected:

View File

@@ -53,13 +53,6 @@ public:
virtual void resolveWitness(const NormalProtocolConformance *conformance,
ValueDecl *requirement) = 0;
/// Resolve the type and declaration attributes of a value.
///
/// This can be called when the type or signature of a value is needed.
/// It does not perform full type-checking, only checks for basic
/// consistency and provides the value a type.
virtual void resolveDeclSignature(ValueDecl *VD) = 0;
/// Resolve any implicitly-declared constructors within the given nominal.
virtual void resolveImplicitConstructors(NominalTypeDecl *nominal) = 0;

View File

@@ -1427,6 +1427,27 @@ public:
void cacheResult(NamedPattern *P) const;
};
class InterfaceTypeRequest :
public SimpleRequest<InterfaceTypeRequest,
Type (ValueDecl *),
CacheKind::SeparatelyCached> {
public:
using SimpleRequest::SimpleRequest;
private:
friend SimpleRequest;
// Evaluation.
llvm::Expected<Type>
evaluate(Evaluator &evaluator, ValueDecl *decl) const;
public:
// Separate caching.
bool isCached() const { return true; }
Optional<Type> getCachedResult() const;
void cacheResult(Type value) const;
};
// Allow AnyValue to compare two Type values, even though Type doesn't
// support ==.
template<>

View File

@@ -67,6 +67,8 @@ SWIFT_REQUEST(TypeChecker, InheritedTypeRequest,
SeparatelyCached, HasNearestLocation)
SWIFT_REQUEST(TypeChecker, InitKindRequest,
CtorInitializerKind(ConstructorDecl *), Cached, NoLocationInfo)
SWIFT_REQUEST(TypeChecker, InterfaceTypeRequest,
Type(ValueDecl *), SeparatelyCached, NoLocationInfo)
SWIFT_REQUEST(TypeChecker, IsAccessorTransparentRequest, bool(AccessorDecl *),
SeparatelyCached, NoLocationInfo)
SWIFT_REQUEST(TypeChecker, IsDynamicRequest, bool(ValueDecl *),