@@ -507,7 +507,7 @@ class alignas(1 << TypeAlignInBits) TypeBase
507507 // / Canonical protocol composition types are minimized only to a certain
508508 // / degree to preserve ABI compatibility. This routine enables performing
509509 // / slower, but stricter minimization at need (e.g. redeclaration checking).
510- CanType getMinimalCanonicalType () const ;
510+ CanType getMinimalCanonicalType (const DeclContext *useDC ) const ;
511511
512512 // / Reconstitute type sugar, e.g., for array types, dictionary
513513 // / types, optionals, etc.
@@ -648,7 +648,8 @@ class alignas(1 << TypeAlignInBits) TypeBase
648648
649649 // / Replace opened archetypes with the given root with their most
650650 // / specific non-dependent upper bounds throughout this type.
651- Type typeEraseOpenedArchetypesWithRoot (const OpenedArchetypeType *root) const ;
651+ Type typeEraseOpenedArchetypesWithRoot (const OpenedArchetypeType *root,
652+ const DeclContext *useDC) const ;
652653
653654 // / Given a declaration context, returns a function type with the 'self'
654655 // / type curried as the input if the declaration context describes a type.
@@ -763,7 +764,8 @@ class alignas(1 << TypeAlignInBits) TypeBase
763764 bool isClassExistentialType ();
764765
765766 // / Opens an existential instance or meta-type and returns the opened type.
766- Type openAnyExistentialType (OpenedArchetypeType *&opened);
767+ Type openAnyExistentialType (OpenedArchetypeType *&opened,
768+ GenericSignature parentSig);
767769
768770 // / Break an existential down into a set of constraints.
769771 ExistentialLayout getExistentialLayout ();
@@ -5189,7 +5191,7 @@ class ProtocolCompositionType final : public TypeBase,
51895191 // / Canonical protocol composition types are minimized only to a certain
51905192 // / degree to preserve ABI compatibility. This routine enables performing
51915193 // / slower, but stricter minimization at need (e.g. redeclaration checking).
5192- CanType getMinimalCanonicalType () const ;
5194+ CanType getMinimalCanonicalType (const DeclContext *useDC ) const ;
51935195
51945196 // / Retrieve the set of members composed to create this type.
51955197 // /
@@ -5272,7 +5274,6 @@ class ParameterizedProtocolType final : public TypeBase,
52725274 friend TrailingObjects;
52735275
52745276 ProtocolType *Base;
5275- Type Arg;
52765277
52775278public:
52785279 // / Retrieve an instance of a protocol composition type with the
@@ -5745,40 +5746,69 @@ class OpenedArchetypeType final : public ArchetypeType,
57455746 ArrayRef<ProtocolDecl *> conformsTo, Type superclass,
57465747 LayoutConstraint layout);
57475748
5749+ public:
5750+ // / Compute the parameter that serves as the \c Self type for an opened
5751+ // / archetype from the given outer generic signature.
5752+ // /
5753+ // / This type is a generic parameter one level deeper
5754+ // / than the deepest generic context depth.
5755+ static Type getSelfInterfaceTypeFromContext (GenericSignature parentSig,
5756+ ASTContext &ctx);
5757+
57485758public:
57495759 // / Get or create an archetype that represents the opened type
57505760 // / of an existential value.
57515761 // /
57525762 // / \param existential The existential type to open.
5763+ // / \param parentSig The generic signature of the context opening
5764+ // / this existential.
57535765 // /
57545766 // / \param knownID When non-empty, the known ID of the archetype. When empty,
57555767 // / a fresh archetype with a unique ID will be opened.
5756- static CanTypeWrapper<OpenedArchetypeType> get (
5757- CanType existential, Optional<UUID> knownID = None);
5768+ static CanTypeWrapper<OpenedArchetypeType> get (CanType existential,
5769+ GenericSignature parentSig,
5770+ Optional<UUID> knownID = None);
57585771
57595772 // / Get or create an archetype that represents the opened type
57605773 // / of an existential value.
57615774 // /
57625775 // / \param existential The existential type to open.
57635776 // / \param interfaceType The interface type represented by this archetype.
5777+ // / \param parentSig The generic signature of the context opening
5778+ // / this existential.
57645779 // /
57655780 // / \param knownID When non-empty, the known ID of the archetype. When empty,
57665781 // / a fresh archetype with a unique ID will be opened.
5767- static CanTypeWrapper<OpenedArchetypeType> get (
5768- CanType existential, Type interfaceType, Optional<UUID> knownID = None);
5782+ static CanTypeWrapper<OpenedArchetypeType> get (CanType existential,
5783+ Type interfaceType,
5784+ GenericSignature parentSig,
5785+ Optional<UUID> knownID = None);
57695786
57705787 // / Create a new archetype that represents the opened type
57715788 // / of an existential value.
57725789 // /
5790+ // / Use this function when you are unsure of whether the
5791+ // / \c existential type is a metatype or an instance type. This function
5792+ // / will unwrap any existential metatype containers.
5793+ // /
57735794 // / \param existential The existential type or existential metatype to open.
57745795 // / \param interfaceType The interface type represented by this archetype.
5775- static CanType getAny (CanType existential, Type interfaceType);
5796+ // / \param parentSig The generic signature of the context opening
5797+ // / this existential.
5798+ static CanType getAny (CanType existential, Type interfaceType,
5799+ GenericSignature parentSig);
57765800
57775801 // / Create a new archetype that represents the opened type
57785802 // / of an existential value.
57795803 // /
5804+ // / Use this function when you are unsure of whether the
5805+ // / \c existential type is a metatype or an instance type. This function
5806+ // / will unwrap any existential metatype containers.
5807+ // /
57805808 // / \param existential The existential type or existential metatype to open.
5781- static CanType getAny (CanType existential);
5809+ // / \param parentSig The generic signature of the context opening
5810+ // / this existential.
5811+ static CanType getAny (CanType existential, GenericSignature parentSig);
57825812
57835813 // / Retrieve the ID number of this opened existential.
57845814 UUID getOpenedExistentialID () const ;
0 commit comments