Give opened archetypes a generic environment.

And maybe allow nested types to live on them.
This commit is contained in:
Joe Groff
2019-01-07 16:03:27 -08:00
parent 345e9881d1
commit 0cfca9496a
16 changed files with 105 additions and 41 deletions

View File

@@ -4695,8 +4695,11 @@ public:
/// Register a nested type with the given name.
void registerNestedType(Identifier name, Type nested);
/// getPrimary - Return the primary archetype parent of this archetype.
PrimaryArchetypeType *getPrimary() const;
/// Return the root archetype parent of this archetype.
ArchetypeType *getRoot() const;
/// Get the generic environment this archetype lives in.
GenericEnvironment *getGenericEnvironment() const;
// Implement isa/cast/dyncast/etc.
static bool classof(const TypeBase *T) {
@@ -4760,7 +4763,8 @@ class OpenedArchetypeType final : public ArchetypeType,
{
friend TrailingObjects;
friend ArchetypeType;
mutable GenericEnvironment *Environment = nullptr;
TypeBase *Opened;
UUID ID;
public:
@@ -4789,12 +4793,17 @@ public:
return Opened;
}
/// Get a generic environment with this opened type bound to its generic
/// parameter.
GenericEnvironment *getGenericEnvironment() const;
static bool classof(const TypeBase *T) {
return T->getKind() == TypeKind::OpenedArchetype;
}
private:
OpenedArchetypeType(const ASTContext &Ctx, Type Existential,
OpenedArchetypeType(const ASTContext &Ctx,
Type Existential,
ArrayRef<ProtocolDecl *> ConformsTo, Type Superclass,
LayoutConstraint Layout, UUID uuid);
};
@@ -4831,6 +4840,10 @@ public:
static bool classof(const TypeBase *T) {
return T->getKind() == TypeKind::NestedArchetype;
}
DependentMemberType *getInterfaceType() const {
return cast<DependentMemberType>(InterfaceType.getPointer());
}
private:
NestedArchetypeType(const ASTContext &Ctx,