mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Add an OpaqueTypeArchetypeType subclass.
This commit is contained in:
@@ -307,6 +307,10 @@ public:
|
||||
/// <t_0_0, t_0_1, t_1_0>
|
||||
/// then this will return 0 for t_0_0, 1 for t_0_1, and 2 for t_1_0.
|
||||
unsigned getGenericParamOrdinal(GenericTypeParamType *param);
|
||||
|
||||
/// Get a substitution map that maps all of the generic signature's
|
||||
/// generic parameters to themselves.
|
||||
SubstitutionMap getIdentitySubstitutionMap() const;
|
||||
|
||||
static void Profile(llvm::FoldingSetNodeID &ID,
|
||||
TypeArrayView<GenericTypeParamType> genericParams,
|
||||
|
||||
@@ -133,6 +133,7 @@ TYPE(DynamicSelf, Type)
|
||||
ABSTRACT_TYPE(Substitutable, Type)
|
||||
ABSTRACT_TYPE(Archetype, SubstitutableType)
|
||||
ALWAYS_CANONICAL_TYPE(PrimaryArchetype, ArchetypeType)
|
||||
ALWAYS_CANONICAL_TYPE(OpaqueTypeArchetype, ArchetypeType)
|
||||
ALWAYS_CANONICAL_TYPE(OpenedArchetype, ArchetypeType)
|
||||
ALWAYS_CANONICAL_TYPE(NestedArchetype, ArchetypeType)
|
||||
TYPE_RANGE(Archetype, PrimaryArchetype, NestedArchetype)
|
||||
|
||||
@@ -53,8 +53,10 @@ namespace swift {
|
||||
class GenericTypeParamType;
|
||||
class GenericParamList;
|
||||
class GenericSignature;
|
||||
class GenericSignatureBuilder;
|
||||
class Identifier;
|
||||
class InOutType;
|
||||
class OpaqueTypeDecl;
|
||||
class OpenedArchetypeType;
|
||||
enum class ReferenceCounting : uint8_t;
|
||||
enum class ResilienceExpansion : unsigned;
|
||||
@@ -4728,6 +4730,65 @@ private:
|
||||
BEGIN_CAN_TYPE_WRAPPER(PrimaryArchetypeType, ArchetypeType)
|
||||
END_CAN_TYPE_WRAPPER(PrimaryArchetypeType, ArchetypeType)
|
||||
|
||||
/// An archetype that represents an opaque type.
|
||||
class OpaqueTypeArchetypeType final : public ArchetypeType,
|
||||
public llvm::FoldingSetNode,
|
||||
private ArchetypeTrailingObjects<OpaqueTypeArchetypeType>
|
||||
{
|
||||
friend TrailingObjects;
|
||||
friend ArchetypeType;
|
||||
friend GenericSignatureBuilder;
|
||||
|
||||
/// The declaration that defines the opaque type.
|
||||
OpaqueTypeDecl *OpaqueDecl;
|
||||
/// The substitutions into the interface signature of the opaque type.
|
||||
SubstitutionMap Substitutions;
|
||||
|
||||
/// The generic signature used to build out this archetype, and its
|
||||
/// nested archetypes.
|
||||
GenericSignature *BoundSignature;
|
||||
|
||||
public:
|
||||
/// Get an opaque archetype representing the underlying type of the given
|
||||
/// opaque type decl.
|
||||
static OpaqueTypeArchetypeType *
|
||||
get(OpaqueTypeDecl *Decl,
|
||||
SubstitutionMap Substitutions);
|
||||
|
||||
OpaqueTypeDecl *getOpaqueDecl() const {
|
||||
return OpaqueDecl;
|
||||
}
|
||||
SubstitutionMap getSubstitutions() const {
|
||||
return Substitutions;
|
||||
}
|
||||
|
||||
/// Get the underlying type of the opaque type, if it's known.
|
||||
Type getUnderlyingType() const;
|
||||
|
||||
static bool classof(const TypeBase *T) {
|
||||
return T->getKind() == TypeKind::OpaqueTypeArchetype;
|
||||
}
|
||||
|
||||
static void Profile(llvm::FoldingSetNodeID &ID,
|
||||
OpaqueTypeDecl *OpaqueDecl,
|
||||
SubstitutionMap Substitutions);
|
||||
|
||||
void Profile(llvm::FoldingSetNodeID &ID) {
|
||||
Profile(ID, getOpaqueDecl(), getSubstitutions());
|
||||
};
|
||||
|
||||
private:
|
||||
OpaqueTypeArchetypeType(OpaqueTypeDecl *OpaqueDecl,
|
||||
SubstitutionMap Substitutions,
|
||||
RecursiveTypeProperties Props,
|
||||
GenericSignature *BoundSignature,
|
||||
Type InterfaceType,
|
||||
ArrayRef<ProtocolDecl*> ConformsTo,
|
||||
Type Superclass, LayoutConstraint Layout);
|
||||
};
|
||||
BEGIN_CAN_TYPE_WRAPPER(OpaqueTypeArchetypeType, ArchetypeType)
|
||||
END_CAN_TYPE_WRAPPER(OpaqueTypeArchetypeType, ArchetypeType)
|
||||
|
||||
/// An archetype that represents the dynamic type of an opened existential.
|
||||
class OpenedArchetypeType final : public ArchetypeType,
|
||||
private ArchetypeTrailingObjects<OpenedArchetypeType>
|
||||
@@ -4834,6 +4895,9 @@ const Type *ArchetypeType::getSubclassTrailingObjects() const {
|
||||
if (auto contextTy = dyn_cast<PrimaryArchetypeType>(this)) {
|
||||
return contextTy->getTrailingObjects<Type>();
|
||||
}
|
||||
if (auto opaqueTy = dyn_cast<OpaqueTypeArchetypeType>(this)) {
|
||||
return opaqueTy->getTrailingObjects<Type>();
|
||||
}
|
||||
if (auto openedTy = dyn_cast<OpenedArchetypeType>(this)) {
|
||||
return openedTy->getTrailingObjects<Type>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user