Skip to content

Commit 89c10f9

Browse files
committed
[Sema] simplify checks in isNoncopyable(DC)
Calling `mapTypeIntoContext` on n interface type with no type parameters is a no-op. In addition, we can avoid calling `getGenericEnvironmentOfContext` twice, which does a search of the DeclContext to find it.
1 parent 0c9d948 commit 89c10f9

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/AST/Type.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,8 @@ bool TypeBase::isNoncopyable(const DeclContext *dc) {
197197
}
198198

199199
if (!hasArchetype() || hasOpenedExistential())
200-
// TODO: the need for the following test is suspicious.
201-
if (dc->getGenericEnvironmentOfContext() || !hasTypeParameter())
202-
return dc->mapTypeIntoContext(this)->isNoncopyable();
200+
if (auto env = dc->getGenericEnvironmentOfContext())
201+
return GenericEnvironment::mapTypeIntoContext(env, this)->isNoncopyable();
203202

204203
return isNoncopyable();
205204
}

0 commit comments

Comments
 (0)