@@ -5548,48 +5548,49 @@ END_CAN_TYPE_WRAPPER(PrimaryArchetypeType, ArchetypeType)
55485548
55495549// / An archetype that represents an opaque type.
55505550class OpaqueTypeArchetypeType final : public ArchetypeType,
5551- public llvm::FoldingSetNode,
55525551 private ArchetypeTrailingObjects<OpaqueTypeArchetypeType>
55535552{
55545553 friend TrailingObjects;
55555554 friend ArchetypeType;
55565555 friend GenericSignatureBuilder;
55575556
5558- // / The declaration that defines the opaque type.
5559- OpaqueTypeDecl *OpaqueDecl;
5560- // / The substitutions into the interface signature of the opaque type.
5561- SubstitutionMap Substitutions;
5562-
55635557 // / A GenericEnvironment with this opaque archetype bound to the interface
55645558 // / type of the output type from the OpaqueDecl.
5565- GenericEnvironment *Environment;
5566-
5559+ GenericEnvironment *Environment = nullptr ;
5560+
5561+ friend class GenericEnvironment ;
5562+
5563+ static OpaqueTypeArchetypeType *getNew (
5564+ GenericEnvironment *environment, Type interfaceType,
5565+ ArrayRef<ProtocolDecl*> conformsTo, Type superclass,
5566+ LayoutConstraint layout);
5567+
55675568public:
55685569 // / Get an opaque archetype representing the underlying type of the given
55695570 // / opaque type decl's opaque param with ordinal `ordinal`. For example, in
55705571 // / `(some P, some Q)`, `some P`'s type param would have ordinal 0 and `some
55715572 // / Q`'s type param would have ordinal 1.
5572- static OpaqueTypeArchetypeType *get (OpaqueTypeDecl *Decl, unsigned ordinal,
5573- SubstitutionMap Substitutions);
5573+ static Type get (OpaqueTypeDecl *decl, unsigned ordinal, SubstitutionMap subs);
5574+
5575+ // / Retrieve the opaque type declaration.
5576+ OpaqueTypeDecl *getDecl () const ;
5577+
5578+ // / Retrieve the set of substitutions applied to the opaque type.
5579+ SubstitutionMap getSubstitutions () const ;
55745580
5575- OpaqueTypeDecl *getDecl () const {
5576- return OpaqueDecl;
5577- }
5578- SubstitutionMap getSubstitutions () const {
5579- return Substitutions;
5580- }
5581-
55825581 // / Get the generic signature used to build out this archetype. This is
55835582 // / equivalent to the OpaqueTypeDecl's interface generic signature, with
55845583 // / all of the generic parameters aside from the opaque type's interface
55855584 // / type same-type-constrained to their substitutions for this type.
55865585 GenericSignature getBoundSignature () const ;
55875586
55885587 // / Get a generic environment that has this opaque archetype bound within it.
5589- GenericEnvironment *getGenericEnvironment () const {
5590- return Environment;
5591- }
5592-
5588+ GenericEnvironment *getGenericEnvironment () const ;
5589+
5590+ // / Compute the canonical interface type within the environment of this
5591+ // / opaque type archetype.
5592+ CanType getCanonicalInterfaceType (Type interfaceType);
5593+
55935594 static bool classof (const TypeBase *T) {
55945595 return T->getKind () == TypeKind::OpaqueTypeArchetype;
55955596 }
@@ -5603,22 +5604,12 @@ class OpaqueTypeArchetypeType final : public ArchetypeType,
56035604 // / then the underlying type of `some P` would be ordinal 0, and `some Q` would be ordinal 1.
56045605 unsigned getOrdinal () const ;
56055606
5606- static void Profile (llvm::FoldingSetNodeID &ID,
5607- OpaqueTypeDecl *OpaqueDecl,
5608- unsigned ordinal,
5609- SubstitutionMap Substitutions);
5610-
5611- void Profile (llvm::FoldingSetNodeID &ID) {
5612- Profile (ID, getDecl (), getOrdinal (), getSubstitutions ());
5613- };
5614-
56155607private:
5616- OpaqueTypeArchetypeType (OpaqueTypeDecl *OpaqueDecl,
5617- SubstitutionMap Substitutions,
5618- RecursiveTypeProperties Props,
5619- Type InterfaceType,
5620- ArrayRef<ProtocolDecl*> ConformsTo,
5621- Type Superclass, LayoutConstraint Layout);
5608+ OpaqueTypeArchetypeType (GenericEnvironment *environment,
5609+ RecursiveTypeProperties properties,
5610+ Type interfaceType,
5611+ ArrayRef<ProtocolDecl*> conformsTo,
5612+ Type superclass, LayoutConstraint layout);
56225613};
56235614BEGIN_CAN_TYPE_WRAPPER (OpaqueTypeArchetypeType, ArchetypeType)
56245615END_CAN_TYPE_WRAPPER(OpaqueTypeArchetypeType, ArchetypeType)
0 commit comments