Skip to content

Commit 2b43b8d

Browse files
committed
[IDE] Simplify ContainsSpecializableArchetype
Remove usage of `GenericTypeParamType::getDecl`. Checking the generic environment is equivalent.
1 parent 9906199 commit 2b43b8d

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

lib/Sema/IDETypeCheckingRequests.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,10 @@ class ContainsSpecializableArchetype : public TypeWalker {
8989

9090
Action walkToTypePre(Type T) override {
9191
if (auto *Archetype = T->getAs<ArchetypeType>()) {
92-
if (auto *GenericTypeParam =
93-
Archetype->mapTypeOutOfContext()->getAs<GenericTypeParamType>()) {
94-
if (auto GenericTypeParamDecl = GenericTypeParam->getDecl()) {
95-
bool ParamMaybeVisibleInCurrentContext =
96-
(DC == GenericTypeParamDecl->getDeclContext() ||
97-
DC->isChildContextOf(GenericTypeParamDecl->getDeclContext()));
98-
if (!ParamMaybeVisibleInCurrentContext) {
99-
Result = true;
100-
return Action::Stop;
101-
}
102-
}
92+
if (Archetype->getGenericEnvironment() !=
93+
DC->getGenericEnvironmentOfContext()) {
94+
Result = true;
95+
return Action::Stop;
10396
}
10497
}
10598
return Action::Continue;

0 commit comments

Comments
 (0)