Skip to content

Commit 47b4493

Browse files
authored
Merge pull request #79917 from eeckstein/rename-opened-archetype-type
AST: rename OpenArchetypeType -> ExistentialArchetypeType
2 parents c7922b2 + d225c47 commit 47b4493

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+153
-150
lines changed

docs/Generics/chapters/types.tex

+1-1
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ \section{Source Code Reference}\label{typesourceref}
759759
\item \texttt{ArchetypeType}, and its three subclasses:
760760
\begin{itemize}
761761
\item \texttt{PrimaryArchetypeType},
762-
\item \texttt{OpenedArchetypeType},
762+
\item \texttt{ExistentialArchetypeType},
763763
\item \texttt{OpaqueArchetypeType}.
764764
\end{itemize}
765765
\item The abstract types:

include/swift/AST/ASTBridgingImpl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ bool BridgedASTType::hasLocalArchetype() const {
403403
}
404404

405405
bool BridgedASTType::isExistentialArchetype() const {
406-
return unbridged()->is<swift::OpenedArchetypeType>();
406+
return unbridged()->is<swift::ExistentialArchetypeType>();
407407
}
408408

409409
bool BridgedASTType::isExistentialArchetypeWithError() const {

include/swift/AST/Expr.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace swift {
5151
class ValueDecl;
5252
class Decl;
5353
class DeclRefExpr;
54-
class OpenedArchetypeType;
54+
class ExistentialArchetypeType;
5555
class ParamDecl;
5656
class Pattern;
5757
class SubscriptDecl;
@@ -3013,7 +3013,7 @@ class OpenExistentialExpr : public Expr {
30133013

30143014
/// Retrieve the opened archetype, which can only be referenced
30153015
/// within this expression's subexpression.
3016-
OpenedArchetypeType *getOpenedArchetype() const;
3016+
ExistentialArchetypeType *getOpenedArchetype() const;
30173017

30183018
static bool classof(const Expr *E) {
30193019
return E->getKind() == ExprKind::OpenExistential;

include/swift/AST/GenericEnvironment.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class ASTContext;
3636
class GenericTypeParamType;
3737
class OpaqueTypeDecl;
3838
class ElementArchetypeType;
39-
class OpenedArchetypeType;
39+
class ExistentialArchetypeType;
4040
class PackArchetypeType;
4141
class PackExpansionType;
4242
class SILModule;

include/swift/AST/TypeMatcher.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ class TypeMatcher {
310310
}
311311
}
312312

313-
// FIXME: Once OpenedArchetypeType stores substitutions, do something
313+
// FIXME: Once ExistentialArchetypeType stores substitutions, do something
314314
// similar to the above.
315315

316316
if (firstArchetype->isEqual(secondType))

include/swift/AST/TypeNodes.def

+2-2
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,9 @@ ABSTRACT_TYPE(Substitutable, Type)
179179
ALWAYS_CANONICAL_TYPE(PrimaryArchetype, ArchetypeType)
180180
ALWAYS_CANONICAL_TYPE(OpaqueTypeArchetype, ArchetypeType)
181181
ABSTRACT_TYPE(LocalArchetype, ArchetypeType)
182-
ALWAYS_CANONICAL_TYPE(OpenedArchetype, LocalArchetypeType)
182+
ALWAYS_CANONICAL_TYPE(ExistentialArchetype, LocalArchetypeType)
183183
ALWAYS_CANONICAL_TYPE(ElementArchetype, LocalArchetypeType)
184-
TYPE_RANGE(LocalArchetype, OpenedArchetype, ElementArchetype)
184+
TYPE_RANGE(LocalArchetype, ExistentialArchetype, ElementArchetype)
185185
ALWAYS_CANONICAL_TYPE(PackArchetype, ArchetypeType)
186186
TYPE_RANGE(Archetype, PrimaryArchetype, PackArchetype)
187187
TYPE(GenericTypeParam, SubstitutableType)

include/swift/AST/TypeTransform.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ case TypeKind::Id:
165165
newSubMap);
166166
}
167167

168-
case TypeKind::OpenedArchetype: {
168+
case TypeKind::ExistentialArchetype: {
169169
auto *local = cast<LocalArchetypeType>(base);
170170
if (auto result = asDerived().transformLocalArchetypeType(local, pos))
171171
return *result;

include/swift/AST/Types.h

+14-11
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class GenericSignatureBuilder;
7575
class Identifier;
7676
class InOutType;
7777
class OpaqueTypeDecl;
78-
class OpenedArchetypeType;
78+
class ExistentialArchetypeType;
7979
class PackExpansionType;
8080
class PackType;
8181
enum class ParamSpecifier : uint8_t;
@@ -114,6 +114,9 @@ enum class TypeKind : uint8_t {
114114
#define TYPE_RANGE(Id, FirstId, LastId) \
115115
First_##Id##Type = FirstId, Last_##Id##Type = LastId,
116116
#include "swift/AST/TypeNodes.def"
117+
// For backward compatibility in LLDB sources.
118+
// TODO: remove this once OpenedArchetype is renamed in LLDB sources.
119+
OpenedArchetype = ExistentialArchetype
117120
};
118121

119122
enum : unsigned {
@@ -6971,16 +6974,16 @@ class LocalArchetypeType : public ArchetypeType {
69716974

69726975
public:
69736976
static bool classof(const TypeBase *type) {
6974-
return type->getKind() == TypeKind::OpenedArchetype ||
6977+
return type->getKind() == TypeKind::ExistentialArchetype ||
69756978
type->getKind() == TypeKind::ElementArchetype;
69766979
}
69776980
};
69786981
BEGIN_CAN_TYPE_WRAPPER(LocalArchetypeType, ArchetypeType)
69796982
END_CAN_TYPE_WRAPPER(LocalArchetypeType, ArchetypeType)
69806983

69816984
/// An archetype that represents the dynamic type of an opened existential.
6982-
class OpenedArchetypeType final : public LocalArchetypeType,
6983-
private ArchetypeTrailingObjects<OpenedArchetypeType>
6985+
class ExistentialArchetypeType final : public LocalArchetypeType,
6986+
private ArchetypeTrailingObjects<ExistentialArchetypeType>
69846987
{
69856988
friend TrailingObjects;
69866989
friend ArchetypeType;
@@ -6991,7 +6994,7 @@ class OpenedArchetypeType final : public LocalArchetypeType,
69916994
///
69926995
/// This is only invoked by the generic environment when mapping the
69936996
/// interface type into context.
6994-
static CanTypeWrapper<OpenedArchetypeType>
6997+
static CanTypeWrapper<ExistentialArchetypeType>
69956998
getNew(GenericEnvironment *environment, Type interfaceType,
69966999
ArrayRef<ProtocolDecl *> conformsTo, Type superclass,
69977000
LayoutConstraint layout);
@@ -7001,7 +7004,7 @@ class OpenedArchetypeType final : public LocalArchetypeType,
70017004
/// of an existential value.
70027005
///
70037006
/// \param existential The existential type to open.
7004-
static CanTypeWrapper<OpenedArchetypeType> get(CanType existential);
7007+
static CanTypeWrapper<ExistentialArchetypeType> get(CanType existential);
70057008

70067009
/// Create a new archetype that represents the opened type
70077010
/// of an existential value.
@@ -7014,18 +7017,18 @@ class OpenedArchetypeType final : public LocalArchetypeType,
70147017
static Type getAny(Type existential);
70157018

70167019
static bool classof(const TypeBase *T) {
7017-
return T->getKind() == TypeKind::OpenedArchetype;
7020+
return T->getKind() == TypeKind::ExistentialArchetype;
70187021
}
70197022

70207023
private:
7021-
OpenedArchetypeType(GenericEnvironment *environment, Type interfaceType,
7024+
ExistentialArchetypeType(GenericEnvironment *environment, Type interfaceType,
70227025
ArrayRef<ProtocolDecl *> conformsTo,
70237026
Type superclass,
70247027
LayoutConstraint layout,
70257028
RecursiveTypeProperties properties);
70267029
};
7027-
BEGIN_CAN_TYPE_WRAPPER(OpenedArchetypeType, LocalArchetypeType)
7028-
END_CAN_TYPE_WRAPPER(OpenedArchetypeType, LocalArchetypeType)
7030+
BEGIN_CAN_TYPE_WRAPPER(ExistentialArchetypeType, LocalArchetypeType)
7031+
END_CAN_TYPE_WRAPPER(ExistentialArchetypeType, LocalArchetypeType)
70297032

70307033
/// A wrapper around a shape type to use in ArchetypeTrailingObjects
70317034
/// for PackArchetypeType.
@@ -7111,7 +7114,7 @@ const Type *ArchetypeType::getSubclassTrailingObjects() const {
71117114
if (auto opaqueTy = dyn_cast<OpaqueTypeArchetypeType>(this)) {
71127115
return opaqueTy->getTrailingObjects<Type>();
71137116
}
7114-
if (auto openedTy = dyn_cast<OpenedArchetypeType>(this)) {
7117+
if (auto openedTy = dyn_cast<ExistentialArchetypeType>(this)) {
71157118
return openedTy->getTrailingObjects<Type>();
71167119
}
71177120
if (auto childTy = dyn_cast<PackArchetypeType>(this)) {

include/swift/SIL/SILCloner.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
383383
return numScalarElements == 1;
384384
}
385385

386-
void remapRootOpenedType(CanOpenedArchetypeType archetypeTy) {
386+
void remapRootOpenedType(CanExistentialArchetypeType archetypeTy) {
387387
auto *origEnv = archetypeTy->getGenericEnvironment();
388388

389389
auto genericSig = origEnv->getGenericSignature();

include/swift/SIL/SILInstruction.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -7773,7 +7773,7 @@ class OpenExistentialAddrInst
77737773

77747774
OpenedExistentialAccess getAccessKind() const { return ForAccess; }
77757775

7776-
CanOpenedArchetypeType getDefinedOpenedArchetype() const {
7776+
CanExistentialArchetypeType getDefinedOpenedArchetype() const {
77777777
const auto archetype = getOpenedArchetypeOf(getType().getASTType());
77787778
assert(archetype && archetype->isRoot() &&
77797779
"Type should be a root opened archetype");
@@ -7794,7 +7794,7 @@ class OpenExistentialValueInst
77947794
ValueOwnershipKind forwardingOwnershipKind);
77957795

77967796
public:
7797-
CanOpenedArchetypeType getDefinedOpenedArchetype() const {
7797+
CanExistentialArchetypeType getDefinedOpenedArchetype() const {
77987798
const auto archetype = getOpenedArchetypeOf(getType().getASTType());
77997799
assert(archetype && archetype->isRoot() &&
78007800
"Type should be a root opened archetype");
@@ -7815,7 +7815,7 @@ class OpenExistentialRefInst
78157815
ValueOwnershipKind forwardingOwnershipKind);
78167816

78177817
public:
7818-
CanOpenedArchetypeType getDefinedOpenedArchetype() const {
7818+
CanExistentialArchetypeType getDefinedOpenedArchetype() const {
78197819
const auto archetype = getOpenedArchetypeOf(getType().getASTType());
78207820
assert(archetype && archetype->isRoot() &&
78217821
"Type should be a root opened archetype");
@@ -7837,7 +7837,7 @@ class OpenExistentialMetatypeInst
78377837
SILType ty);
78387838

78397839
public:
7840-
CanOpenedArchetypeType getDefinedOpenedArchetype() const {
7840+
CanExistentialArchetypeType getDefinedOpenedArchetype() const {
78417841
const auto archetype = getOpenedArchetypeOf(getType().getASTType());
78427842
assert(archetype && archetype->isRoot() &&
78437843
"Type should be a root opened archetype");
@@ -7858,7 +7858,7 @@ class OpenExistentialBoxInst
78587858
SILType ty);
78597859

78607860
public:
7861-
CanOpenedArchetypeType getDefinedOpenedArchetype() const {
7861+
CanExistentialArchetypeType getDefinedOpenedArchetype() const {
78627862
const auto archetype = getOpenedArchetypeOf(getType().getASTType());
78637863
assert(archetype && archetype->isRoot() &&
78647864
"Type should be a root opened archetype");
@@ -7879,7 +7879,7 @@ class OpenExistentialBoxValueInst
78797879
ValueOwnershipKind forwardingOwnershipKind);
78807880

78817881
public:
7882-
CanOpenedArchetypeType getDefinedOpenedArchetype() const {
7882+
CanExistentialArchetypeType getDefinedOpenedArchetype() const {
78837883
const auto archetype = getOpenedArchetypeOf(getType().getASTType());
78847884
assert(archetype && archetype->isRoot() &&
78857885
"Type should be a root opened archetype");

include/swift/SIL/SILType.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ namespace swift {
4949
/// recursively check any children of this type, because
5050
/// this is the task of the type visitor invoking it.
5151
/// \returns The found opened archetype or empty type otherwise.
52-
CanOpenedArchetypeType getOpenedArchetypeOf(CanType Ty);
52+
CanExistentialArchetypeType getOpenedArchetypeOf(CanType Ty);
5353
CanLocalArchetypeType getLocalArchetypeOf(CanType Ty);
5454

5555
/// How an existential type container is represented.

include/swift/SILOptimizer/Differentiation/Thunk.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class SILOptFunctionBuilder;
2727
class SILModule;
2828
class SILLocation;
2929
class SILValue;
30-
class OpenedArchetypeType;
30+
class ExistentialArchetypeType;
3131
class GenericEnvironment;
3232
class SubstitutionMap;
3333
class ArchetypeType;

include/swift/SILOptimizer/Utils/Existential.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace swift {
3333
/// When successful, ConcreteExistentialInfo can be used to determine the
3434
/// concrete type of the opened existential.
3535
struct OpenedArchetypeInfo {
36-
OpenedArchetypeType *OpenedArchetype = nullptr;
36+
ExistentialArchetypeType *OpenedArchetype = nullptr;
3737
// The opened value.
3838
SingleValueInstruction *OpenedArchetypeValue;
3939
// The existential value.

include/swift/Sema/ConstraintSystem.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -1554,7 +1554,7 @@ class Solution {
15541554
llvm::DenseMap<ConstraintLocator *, ArrayRef<OpenedType>> OpenedTypes;
15551555

15561556
/// The opened existential type for a given locator.
1557-
llvm::DenseMap<ConstraintLocator *, OpenedArchetypeType *>
1557+
llvm::DenseMap<ConstraintLocator *, ExistentialArchetypeType *>
15581558
OpenedExistentialTypes;
15591559

15601560
llvm::DenseMap<PackExpansionType *, TypeVariableType *>
@@ -2420,7 +2420,7 @@ class ConstraintSystem {
24202420

24212421
/// A mapping from constraint locators to the opened existential archetype
24222422
/// used for the 'self' of an existential type.
2423-
llvm::SmallDenseMap<ConstraintLocator *, OpenedArchetypeType *, 4>
2423+
llvm::SmallDenseMap<ConstraintLocator *, ExistentialArchetypeType *, 4>
24242424
OpenedExistentialTypes;
24252425

24262426
llvm::SmallDenseMap<PackExpansionType *, TypeVariableType *, 4>
@@ -3380,12 +3380,12 @@ class ConstraintSystem {
33803380
/// Open the given existential type or existential metatype, recording the
33813381
/// opened archetype in the constraint system and returning both the opened
33823382
/// type and opened archetype.
3383-
std::pair<Type, OpenedArchetypeType *>
3383+
std::pair<Type, ExistentialArchetypeType *>
33843384
openAnyExistentialType(Type type, ConstraintLocator *locator);
33853385

33863386
/// Update OpenedExistentials and record a change in the trail.
33873387
void recordOpenedExistentialType(ConstraintLocator *locator,
3388-
OpenedArchetypeType *opened);
3388+
ExistentialArchetypeType *opened);
33893389

33903390
/// Retrieve the generic environment for the opened element of a given pack
33913391
/// expansion, or \c nullptr if no environment was recorded yet.

lib/AST/ASTContext.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -5595,55 +5595,55 @@ Type OpaqueTypeArchetypeType::get(
55955595
return env->getOrCreateArchetypeFromInterfaceType(interfaceType);
55965596
}
55975597

5598-
CanTypeWrapper<OpenedArchetypeType> OpenedArchetypeType::getNew(
5598+
CanTypeWrapper<ExistentialArchetypeType> ExistentialArchetypeType::getNew(
55995599
GenericEnvironment *environment, Type interfaceType,
56005600
ArrayRef<ProtocolDecl *> conformsTo, Type superclass,
56015601
LayoutConstraint layout) {
56025602
auto properties = archetypeProperties(
56035603
RecursiveTypeProperties::HasOpenedExistential, conformsTo, superclass,
56045604
environment->getOuterSubstitutions());
56055605
auto arena = getArena(properties);
5606-
auto size = OpenedArchetypeType::totalSizeToAlloc<
5606+
auto size = ExistentialArchetypeType::totalSizeToAlloc<
56075607
ProtocolDecl *, Type, LayoutConstraint>(
56085608
conformsTo.size(),
56095609
superclass ? 1 : 0,
56105610
layout ? 1 : 0);
56115611

56125612
ASTContext &ctx = interfaceType->getASTContext();
5613-
void *mem = ctx.Allocate(size, alignof(OpenedArchetypeType), arena);
5613+
void *mem = ctx.Allocate(size, alignof(ExistentialArchetypeType), arena);
56145614

5615-
return CanOpenedArchetypeType(::new (mem) OpenedArchetypeType(
5615+
return CanExistentialArchetypeType(::new (mem) ExistentialArchetypeType(
56165616
environment, interfaceType, conformsTo, superclass, layout,
56175617
properties));
56185618
}
56195619

5620-
CanOpenedArchetypeType OpenedArchetypeType::get(CanType existential) {
5620+
CanExistentialArchetypeType ExistentialArchetypeType::get(CanType existential) {
56215621
auto &ctx = existential->getASTContext();
56225622
auto existentialSig = ctx.getOpenedExistentialSignature(existential);
56235623

56245624
auto *genericEnv = GenericEnvironment::forOpenedExistential(
56255625
existentialSig.OpenedSig, existentialSig.Shape,
56265626
existentialSig.Generalization, UUID::fromTime());
56275627

5628-
return cast<OpenedArchetypeType>(
5628+
return cast<ExistentialArchetypeType>(
56295629
genericEnv->mapTypeIntoContext(existentialSig.SelfType)
56305630
->getCanonicalType());
56315631
}
56325632

5633-
Type OpenedArchetypeType::getAny(Type existential) {
5633+
Type ExistentialArchetypeType::getAny(Type existential) {
56345634
assert(existential->isAnyExistentialType());
56355635

56365636
if (auto metatypeTy = existential->getAs<ExistentialMetatypeType>()) {
56375637
auto instanceTy = metatypeTy->getExistentialInstanceType();
5638-
auto openedInstanceTy = OpenedArchetypeType::getAny(instanceTy);
5638+
auto openedInstanceTy = ExistentialArchetypeType::getAny(instanceTy);
56395639
if (metatypeTy->hasRepresentation()) {
56405640
return MetatypeType::get(openedInstanceTy,
56415641
metatypeTy->getRepresentation());
56425642
}
56435643
return MetatypeType::get(openedInstanceTy);
56445644
}
56455645

5646-
return OpenedArchetypeType::get(existential->getCanonicalType());
5646+
return ExistentialArchetypeType::get(existential->getCanonicalType());
56475647
}
56485648

56495649
void SubstitutionMap::Storage::Profile(

lib/AST/ASTDumper.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -6105,8 +6105,8 @@ namespace {
61056105

61066106
printFoot();
61076107
}
6108-
void visitOpenedArchetypeType(OpenedArchetypeType *T, Label label) {
6109-
printArchetypeCommon(T, "opened_archetype_type", label);
6108+
void visitExistentialArchetypeType(ExistentialArchetypeType *T, Label label) {
6109+
printArchetypeCommon(T, "existential_archetype_type", label);
61106110

61116111
auto *env = T->getGenericEnvironment();
61126112
printFieldQuoted(env->getOpenedExistentialUUID(),

lib/AST/ASTMangler.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ std::string ASTMangler::mangleKeyPathGetterThunkHelper(
396396
// FIXME: This seems wrong. We used to just mangle opened archetypes as
397397
// their interface type. Let's make that explicit now.
398398
sub = sub.transformRec([](Type t) -> std::optional<Type> {
399-
if (auto *openedExistential = t->getAs<OpenedArchetypeType>()) {
399+
if (auto *openedExistential = t->getAs<ExistentialArchetypeType>()) {
400400
auto &ctx = openedExistential->getASTContext();
401401
return GenericTypeParamType::getType(0, 0, ctx);
402402
}
@@ -432,7 +432,7 @@ std::string ASTMangler::mangleKeyPathSetterThunkHelper(
432432
// FIXME: This seems wrong. We used to just mangle opened archetypes as
433433
// their interface type. Let's make that explicit now.
434434
sub = sub.transformRec([](Type t) -> std::optional<Type> {
435-
if (auto *openedExistential = t->getAs<OpenedArchetypeType>()) {
435+
if (auto *openedExistential = t->getAs<ExistentialArchetypeType>()) {
436436
auto &ctx = openedExistential->getASTContext();
437437
return GenericTypeParamType::getType(0, 0, ctx);
438438
}
@@ -1675,7 +1675,7 @@ void ASTMangler::appendType(Type type, GenericSignature sig,
16751675
case TypeKind::PrimaryArchetype:
16761676
case TypeKind::PackArchetype:
16771677
case TypeKind::ElementArchetype:
1678-
case TypeKind::OpenedArchetype:
1678+
case TypeKind::ExistentialArchetype:
16791679
llvm::errs() << "Cannot mangle free-standing archetype: ";
16801680
tybase->dump(llvm::errs());
16811681
abort();

0 commit comments

Comments
 (0)