@@ -168,7 +168,10 @@ class RecursiveTypeProperties {
168
168
// / This type contains a parameterized existential type \c any P<T>.
169
169
HasParameterizedExistential = 0x2000 ,
170
170
171
- Last_Property = HasParameterizedExistential
171
+ // / This type contains an ElementArchetype.
172
+ HasElementArchetype = 0x4000 ,
173
+
174
+ Last_Property = HasElementArchetype
172
175
};
173
176
enum { BitWidth = countBitsUsed (Property::Last_Property) };
174
177
@@ -212,9 +215,19 @@ class RecursiveTypeProperties {
212
215
bool hasDependentMember () const { return Bits & HasDependentMember; }
213
216
214
217
// / Does a type with these properties structurally contain an
215
- // / archetype?
218
+ // / opened existential archetype?
216
219
bool hasOpenedExistential () const { return Bits & HasOpenedExistential; }
217
220
221
+ // / Does a type with these properties structurally contain an
222
+ // / opened element archetype?
223
+ bool hasElementArchetype () const { return Bits & HasElementArchetype; }
224
+
225
+ // / Does a type with these properties structurally contain a local
226
+ // / archetype?
227
+ bool hasLocalArchetype () const {
228
+ return hasOpenedExistential () || hasElementArchetype ();
229
+ }
230
+
218
231
// / Does a type with these properties structurally contain a
219
232
// / reference to DynamicSelf?
220
233
bool hasDynamicSelf () const { return Bits & HasDynamicSelf; }
@@ -629,6 +642,16 @@ class alignas(1 << TypeAlignInBits) TypeBase
629
642
return getRecursiveProperties ().hasOpenedExistential ();
630
643
}
631
644
645
+ // / Determine whether the type involves an opened element archetype.
646
+ bool hasElementArchetype () const {
647
+ return getRecursiveProperties ().hasElementArchetype ();
648
+ }
649
+
650
+ // / Determine whether the type involves a local archetype.
651
+ bool hasLocalArchetype () const {
652
+ return getRecursiveProperties ().hasLocalArchetype ();
653
+ }
654
+
632
655
bool hasParameterPack () const {
633
656
return getRecursiveProperties ().hasParameterPack ();
634
657
}
@@ -5914,8 +5937,29 @@ class ReplaceOpaqueTypesWithUnderlyingTypes {
5914
5937
bool isWholeModule () const { return inContextAndIsWholeModule.getInt (); }
5915
5938
};
5916
5939
5940
+ // / An archetype that's only valid in a portion of a local context.
5941
+ class LocalArchetypeType : public ArchetypeType {
5942
+ protected:
5943
+ using ArchetypeType::ArchetypeType;
5944
+
5945
+ public:
5946
+ LocalArchetypeType *getRoot () const {
5947
+ return cast<LocalArchetypeType>(ArchetypeType::getRoot ());
5948
+ }
5949
+
5950
+ static bool classof (const TypeBase *type) {
5951
+ return type->getKind () == TypeKind::OpenedArchetype ||
5952
+ type->getKind () == TypeKind::ElementArchetype;
5953
+ }
5954
+ };
5955
+ BEGIN_CAN_TYPE_WRAPPER (LocalArchetypeType, ArchetypeType)
5956
+ CanLocalArchetypeType getRoot() const {
5957
+ return CanLocalArchetypeType (getPointer ()->getRoot ());
5958
+ }
5959
+ END_CAN_TYPE_WRAPPER (LocalArchetypeType, ArchetypeType)
5960
+
5917
5961
// / An archetype that represents the dynamic type of an opened existential.
5918
- class OpenedArchetypeType final : public ArchetypeType ,
5962
+ class OpenedArchetypeType final : public LocalArchetypeType ,
5919
5963
private ArchetypeTrailingObjects<OpenedArchetypeType>
5920
5964
{
5921
5965
friend TrailingObjects;
@@ -6016,11 +6060,11 @@ class OpenedArchetypeType final : public ArchetypeType,
6016
6060
ArrayRef<ProtocolDecl *> conformsTo, Type superclass,
6017
6061
LayoutConstraint layout);
6018
6062
};
6019
- BEGIN_CAN_TYPE_WRAPPER (OpenedArchetypeType, ArchetypeType )
6063
+ BEGIN_CAN_TYPE_WRAPPER (OpenedArchetypeType, LocalArchetypeType )
6020
6064
CanOpenedArchetypeType getRoot() const {
6021
6065
return CanOpenedArchetypeType (getPointer ()->getRoot ());
6022
6066
}
6023
- END_CAN_TYPE_WRAPPER (OpenedArchetypeType, ArchetypeType )
6067
+ END_CAN_TYPE_WRAPPER (OpenedArchetypeType, LocalArchetypeType )
6024
6068
6025
6069
// / A wrapper around a shape type to use in ArchetypeTrailingObjects
6026
6070
// / for PackArchetypeType.
@@ -6065,7 +6109,7 @@ BEGIN_CAN_TYPE_WRAPPER(PackArchetypeType, ArchetypeType)
6065
6109
END_CAN_TYPE_WRAPPER(PackArchetypeType, ArchetypeType)
6066
6110
6067
6111
// / An archetype that represents the element type of a pack archetype.
6068
- class ElementArchetypeType final : public ArchetypeType ,
6112
+ class ElementArchetypeType final : public LocalArchetypeType ,
6069
6113
private ArchetypeTrailingObjects<ElementArchetypeType>
6070
6114
{
6071
6115
friend TrailingObjects;
@@ -6104,11 +6148,11 @@ class ElementArchetypeType final : public ArchetypeType,
6104
6148
ArrayRef<ProtocolDecl *> conformsTo, Type superclass,
6105
6149
LayoutConstraint layout);
6106
6150
};
6107
- BEGIN_CAN_TYPE_WRAPPER (ElementArchetypeType, ArchetypeType )
6151
+ BEGIN_CAN_TYPE_WRAPPER (ElementArchetypeType, LocalArchetypeType )
6108
6152
CanElementArchetypeType getRoot() const {
6109
6153
return CanElementArchetypeType (getPointer ()->getRoot ());
6110
6154
}
6111
- END_CAN_TYPE_WRAPPER (ElementArchetypeType, ArchetypeType )
6155
+ END_CAN_TYPE_WRAPPER (ElementArchetypeType, LocalArchetypeType )
6112
6156
6113
6157
template<typename Type>
6114
6158
const Type *ArchetypeType::getSubclassTrailingObjects() const {
0 commit comments