@@ -507,7 +507,7 @@ class alignas(1 << TypeAlignInBits) TypeBase
507
507
// / Canonical protocol composition types are minimized only to a certain
508
508
// / degree to preserve ABI compatibility. This routine enables performing
509
509
// / slower, but stricter minimization at need (e.g. redeclaration checking).
510
- CanType getMinimalCanonicalType () const ;
510
+ CanType getMinimalCanonicalType (const DeclContext *useDC ) const ;
511
511
512
512
// / Reconstitute type sugar, e.g., for array types, dictionary
513
513
// / types, optionals, etc.
@@ -648,7 +648,8 @@ class alignas(1 << TypeAlignInBits) TypeBase
648
648
649
649
// / Replace opened archetypes with the given root with their most
650
650
// / 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 ;
652
653
653
654
// / Given a declaration context, returns a function type with the 'self'
654
655
// / type curried as the input if the declaration context describes a type.
@@ -763,7 +764,8 @@ class alignas(1 << TypeAlignInBits) TypeBase
763
764
bool isClassExistentialType ();
764
765
765
766
// / 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);
767
769
768
770
// / Break an existential down into a set of constraints.
769
771
ExistentialLayout getExistentialLayout ();
@@ -5189,7 +5191,7 @@ class ProtocolCompositionType final : public TypeBase,
5189
5191
// / Canonical protocol composition types are minimized only to a certain
5190
5192
// / degree to preserve ABI compatibility. This routine enables performing
5191
5193
// / slower, but stricter minimization at need (e.g. redeclaration checking).
5192
- CanType getMinimalCanonicalType () const ;
5194
+ CanType getMinimalCanonicalType (const DeclContext *useDC ) const ;
5193
5195
5194
5196
// / Retrieve the set of members composed to create this type.
5195
5197
// /
@@ -5272,7 +5274,6 @@ class ParameterizedProtocolType final : public TypeBase,
5272
5274
friend TrailingObjects;
5273
5275
5274
5276
ProtocolType *Base;
5275
- Type Arg;
5276
5277
5277
5278
public:
5278
5279
// / Retrieve an instance of a protocol composition type with the
@@ -5745,40 +5746,69 @@ class OpenedArchetypeType final : public ArchetypeType,
5745
5746
ArrayRef<ProtocolDecl *> conformsTo, Type superclass,
5746
5747
LayoutConstraint layout);
5747
5748
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
+
5748
5758
public:
5749
5759
// / Get or create an archetype that represents the opened type
5750
5760
// / of an existential value.
5751
5761
// /
5752
5762
// / \param existential The existential type to open.
5763
+ // / \param parentSig The generic signature of the context opening
5764
+ // / this existential.
5753
5765
// /
5754
5766
// / \param knownID When non-empty, the known ID of the archetype. When empty,
5755
5767
// / 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);
5758
5771
5759
5772
// / Get or create an archetype that represents the opened type
5760
5773
// / of an existential value.
5761
5774
// /
5762
5775
// / \param existential The existential type to open.
5763
5776
// / \param interfaceType The interface type represented by this archetype.
5777
+ // / \param parentSig The generic signature of the context opening
5778
+ // / this existential.
5764
5779
// /
5765
5780
// / \param knownID When non-empty, the known ID of the archetype. When empty,
5766
5781
// / 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);
5769
5786
5770
5787
// / Create a new archetype that represents the opened type
5771
5788
// / of an existential value.
5772
5789
// /
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
+ // /
5773
5794
// / \param existential The existential type or existential metatype to open.
5774
5795
// / \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);
5776
5800
5777
5801
// / Create a new archetype that represents the opened type
5778
5802
// / of an existential value.
5779
5803
// /
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
+ // /
5780
5808
// / \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);
5782
5812
5783
5813
// / Retrieve the ID number of this opened existential.
5784
5814
UUID getOpenedExistentialID () const ;
0 commit comments