Skip to content

Commit 7a97036

Browse files
committed
AST: Rename GenericEnvironment::Kind::Normal to ::Primary, ::getIncomplete() to ::forPrimary()
1 parent 87eb2ca commit 7a97036

File tree

4 files changed

+14
-17
lines changed

4 files changed

+14
-17
lines changed

include/swift/AST/GenericEnvironment.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class alignas(1 << DeclAlignInBits) GenericEnvironment final
7373
enum class Kind {
7474
/// A normal generic environment, determined only by its generic
7575
/// signature.
76-
Normal,
76+
Primary,
7777
/// A generic environment describing an opened existential archetype.
7878
OpenedExistential,
7979
/// A generic environment describing an opaque type archetype.
@@ -84,7 +84,7 @@ class alignas(1 << DeclAlignInBits) GenericEnvironment final
8484

8585
private:
8686
mutable llvm::PointerIntPair<GenericSignature, 2, Kind> SignatureAndKind{
87-
GenericSignature(), Kind::Normal};
87+
GenericSignature(), Kind::Primary};
8888
NestedTypeStorage *nestedTypeStorage = nullptr;
8989

9090
friend TrailingObjects;
@@ -151,10 +151,8 @@ class alignas(1 << DeclAlignInBits) GenericEnvironment final
151151
/// create a generic environment.
152152
SubstitutionMap getOpaqueSubstitutions() const;
153153

154-
/// Create a new, "incomplete" generic environment that will be populated
155-
/// by calls to \c addMapping().
156-
static
157-
GenericEnvironment *getIncomplete(GenericSignature signature);
154+
/// Create a new, primary generic environment.
155+
static GenericEnvironment *forPrimary(GenericSignature signature);
158156

159157
/// Create a new generic environment for an opened existential.
160158
///

lib/AST/ASTContext.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4637,8 +4637,7 @@ GenericSignature::get(TypeArrayView<GenericTypeParamType> params,
46374637
return newSig;
46384638
}
46394639

4640-
GenericEnvironment *GenericEnvironment::getIncomplete(
4641-
GenericSignature signature) {
4640+
GenericEnvironment *GenericEnvironment::forPrimary(GenericSignature signature) {
46424641
auto &ctx = signature->getASTContext();
46434642

46444643
// Allocate and construct the new environment.

lib/AST/GenericEnvironment.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ using namespace swift;
2626
size_t GenericEnvironment::numTrailingObjects(
2727
OverloadToken<OpaqueTypeDecl *>) const {
2828
switch (getKind()) {
29-
case Kind::Normal:
29+
case Kind::Primary:
3030
case Kind::OpenedExistential:
3131
return 0;
3232

@@ -38,7 +38,7 @@ size_t GenericEnvironment::numTrailingObjects(
3838
size_t GenericEnvironment::numTrailingObjects(
3939
OverloadToken<SubstitutionMap>) const {
4040
switch (getKind()) {
41-
case Kind::Normal:
41+
case Kind::Primary:
4242
case Kind::OpenedExistential:
4343
return 0;
4444

@@ -50,7 +50,7 @@ size_t GenericEnvironment::numTrailingObjects(
5050
size_t GenericEnvironment::numTrailingObjects(
5151
OverloadToken<OpenedGenericEnvironmentData>) const {
5252
switch (getKind()) {
53-
case Kind::Normal:
53+
case Kind::Primary:
5454
case Kind::Opaque:
5555
return 0;
5656

@@ -105,7 +105,7 @@ UUID GenericEnvironment::getOpenedExistentialUUID() const {
105105
}
106106

107107
GenericEnvironment::GenericEnvironment(GenericSignature signature)
108-
: SignatureAndKind(signature, Kind::Normal)
108+
: SignatureAndKind(signature, Kind::Primary)
109109
{
110110
// Clear out the memory that holds the context types.
111111
std::uninitialized_fill(getContextTypes().begin(), getContextTypes().end(),
@@ -209,7 +209,7 @@ struct SubstituteOuterFromSubstitutionMap {
209209

210210
Type GenericEnvironment::maybeApplyOpaqueTypeSubstitutions(Type type) const {
211211
switch (getKind()) {
212-
case Kind::Normal:
212+
case Kind::Primary:
213213
case Kind::OpenedExistential:
214214
return type;
215215

@@ -283,7 +283,7 @@ GenericEnvironment::getOrCreateArchetypeFromInterfaceType(Type depType) {
283283
/// Substitute a type for the purpose of requirements.
284284
auto substForRequirements = [&](Type type) {
285285
switch (getKind()) {
286-
case Kind::Normal:
286+
case Kind::Primary:
287287
case Kind::OpenedExistential:
288288
if (type->hasTypeParameter()) {
289289
return mapTypeIntoContext(type, conformanceLookupFn);
@@ -334,13 +334,13 @@ GenericEnvironment::getOrCreateArchetypeFromInterfaceType(Type depType) {
334334

335335
auto rootGP = requirements.anchor->getRootGenericParam();
336336
if (rootGP->isTypeSequence()) {
337-
assert(getKind() == Kind::Normal);
337+
assert(getKind() == Kind::Primary);
338338
result = SequenceArchetypeType::get(ctx, this, requirements.anchor,
339339
requirements.protos, superclass,
340340
requirements.layout);
341341
} else {
342342
switch (getKind()) {
343-
case Kind::Normal:
343+
case Kind::Primary:
344344
result = PrimaryArchetypeType::getNew(ctx, this, requirements.anchor,
345345
requirements.protos, superclass,
346346
requirements.layout);

lib/AST/GenericSignature.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ GenericEnvironment *GenericSignature::getGenericEnvironment() const {
267267
GenericEnvironment *GenericSignatureImpl::getGenericEnvironment() const {
268268
if (GenericEnv == nullptr) {
269269
const auto impl = const_cast<GenericSignatureImpl *>(this);
270-
impl->GenericEnv = GenericEnvironment::getIncomplete(this);
270+
impl->GenericEnv = GenericEnvironment::forPrimary(this);
271271
}
272272

273273
return GenericEnv;

0 commit comments

Comments
 (0)