AST: GenericContexts store a GenericSignature instead of a GenericEnvironment

This eliminates the entire 'lazy generic environment' concept;
essentially, all generic environments are now lazy, and since
each signature has exactly one environment, their construction
no longer needs to be co-ordinated with deserialization.
This commit is contained in:
Slava Pestov
2019-09-05 18:16:38 -04:00
parent e027c82f37
commit 0405ab5ffc
11 changed files with 48 additions and 196 deletions

View File

@@ -1482,18 +1482,11 @@ public:
/// moves the trailing where clause into the generic parameter list.
TrailingWhereClause *TrailingWhere = nullptr;
/// The generic signature or environment of this declaration.
///
/// When this declaration stores only a signature, the generic
/// environment will be lazily loaded.
mutable llvm::PointerUnion<GenericSignature *, GenericEnvironment *>
GenericSigOrEnv;
/// The generic signature of this declaration.
GenericSignature *GenericSig = nullptr;
};
class GenericContext : private _GenericContext, public DeclContext {
/// Lazily populate the generic environment.
GenericEnvironment *getLazyGenericEnvironmentSlow() const;
protected:
GenericContext(DeclContextKind Kind, DeclContext *Parent)
: _GenericContext(), DeclContext(Kind, Parent) { }
@@ -1542,18 +1535,12 @@ public:
/// Retrieve the generic requirements.
ArrayRef<Requirement> getGenericRequirements() const;
/// Set a lazy generic environment.
void setLazyGenericEnvironment(LazyMemberLoader *lazyLoader,
GenericSignature *genericSig,
uint64_t genericEnvData);
/// Whether this generic context has a lazily-created generic environment
/// that has not yet been constructed.
bool hasLazyGenericEnvironment() const;
/// Set the generic context of this context.
void setGenericEnvironment(GenericEnvironment *genericEnv);
/// Set the generic signature of this context.
void setGenericSignature(GenericSignature *genericSig);
/// Retrieve the position of any where clause for this context's
/// generic parameters.
SourceRange getGenericTrailingWhereClauseSourceRange() const;