Skip to content

Commit 6def545

Browse files
committed
AST: Remove GenericEnvironment::containsPrimaryArchetype()
This is no longer necessary now that archetypes refer back to a GenericEnvironment.
1 parent 04b8712 commit 6def545

File tree

5 files changed

+4
-14
lines changed

5 files changed

+4
-14
lines changed

include/swift/AST/GenericEnvironment.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,6 @@ class alignas(1 << DeclAlignInBits) GenericEnvironment final
151151
return Signature->getGenericParams();
152152
}
153153

154-
/// Determine whether this generic environment contains the given
155-
/// primary archetype.
156-
bool containsPrimaryArchetype(ArchetypeType *archetype) const;
157-
158154
/// Create a new, "incomplete" generic environment that will be populated
159155
/// by calls to \c addMapping().
160156
static

lib/AST/ASTVerifier.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,11 @@ struct LazyGenericEnvironment {
170170
if (isLazy()) return true;
171171

172172
if (auto genericEnv = storage.dyn_cast<GenericEnvironment *>())
173-
return genericEnv->containsPrimaryArchetype(archetype);
173+
return archetype->getGenericEnvironment() == genericEnv;
174174

175175
if (auto dc = storage.dyn_cast<DeclContext *>()) {
176176
if (auto genericEnv = dc->getGenericEnvironmentOfContext())
177-
return genericEnv->containsPrimaryArchetype(archetype);
177+
return archetype->getGenericEnvironment() == genericEnv;
178178
}
179179

180180
return false;

lib/AST/GenericEnvironment.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,6 @@ Optional<Type> GenericEnvironment::getMappingIfPresent(
138138
return None;
139139
}
140140

141-
bool GenericEnvironment::containsPrimaryArchetype(
142-
ArchetypeType *archetype) const {
143-
return static_cast<bool>(
144-
QueryArchetypeToInterfaceSubstitutions(this)(archetype));
145-
}
146-
147141
Type GenericEnvironment::mapTypeIntoContext(GenericEnvironment *env,
148142
Type type) {
149143
assert(!type->hasArchetype() && "already have a contextual type");

lib/SIL/SILVerifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static bool isArchetypeValidInFunction(ArchetypeType *A, const SILFunction *F) {
6969
// Ok, we have a primary archetype, make sure it is in the nested generic
7070
// environment of our caller.
7171
if (auto *genericEnv = F->getGenericEnvironment())
72-
if (genericEnv->containsPrimaryArchetype(A))
72+
if (A->getGenericEnvironment() == genericEnv)
7373
return true;
7474

7575
return false;

lib/Sema/CSDiag.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8998,7 +8998,7 @@ static bool hasArchetype(const GenericTypeDecl *generic,
89988998
if (!genericEnv)
89998999
return false;
90009000

9001-
return genericEnv->containsPrimaryArchetype(archetype);
9001+
return archetype->getGenericEnvironment() == genericEnv;
90029002
}
90039003

90049004
static void noteArchetypeSource(const TypeLoc &loc, ArchetypeType *archetype,

0 commit comments

Comments
 (0)