Skip to content

Commit 5004159

Browse files
committed
[Sema] NFC: Inline removeValidObjCConflictingMethods
1 parent 05d377d commit 5004159

File tree

1 file changed

+17
-33
lines changed

1 file changed

+17
-33
lines changed

lib/Sema/TypeCheckDeclObjC.cpp

Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2082,37 +2082,6 @@ getObjCMethodConflictDecls(const SourceFile::ObjCMethodConflict &conflict) {
20822082
return classDecl->lookupDirect(selector, isInstanceMethod);
20832083
}
20842084

2085-
/// Given a set of conflicting Objective-C methods, remove any methods
2086-
/// that are legitimately overridden in Objective-C, i.e., because
2087-
/// they occur in different modules, one is defined in the class, and
2088-
/// the other is defined in an extension (category) thereof.
2089-
static void removeValidObjCConflictingMethods(
2090-
MutableArrayRef<AbstractFunctionDecl *> &methods) {
2091-
// Erase any invalid or stub declarations. We don't want to complain about
2092-
// them, because we might already have complained about
2093-
// redeclarations based on Swift matching.
2094-
auto newEnd = std::remove_if(methods.begin(), methods.end(),
2095-
[&](AbstractFunctionDecl *method) {
2096-
if (method->isInvalid())
2097-
return true;
2098-
2099-
if (auto ad = dyn_cast<AccessorDecl>(method)) {
2100-
return ad->getStorage()->isInvalid();
2101-
}
2102-
2103-
if (auto ctor
2104-
= dyn_cast<ConstructorDecl>(method)) {
2105-
if (ctor->hasStubImplementation())
2106-
return true;
2107-
2108-
return false;
2109-
}
2110-
2111-
return false;
2112-
});
2113-
methods = methods.slice(0, newEnd - methods.begin());
2114-
}
2115-
21162085
bool swift::diagnoseObjCMethodConflicts(SourceFile &sf) {
21172086
// If there were no conflicts, we're done.
21182087
if (sf.ObjCMethodConflicts.empty())
@@ -2140,8 +2109,23 @@ bool swift::diagnoseObjCMethodConflicts(SourceFile &sf) {
21402109

21412110
auto methods = getObjCMethodConflictDecls(conflict);
21422111

2143-
// Prune out cases where it is acceptable to have a conflict.
2144-
removeValidObjCConflictingMethods(methods);
2112+
// Erase any invalid or stub declarations. We don't want to complain about
2113+
// them, because we might already have complained about redeclarations
2114+
// based on Swift matching.
2115+
llvm::erase_if(methods, [](AbstractFunctionDecl *afd) -> bool {
2116+
if (afd->isInvalid())
2117+
return true;
2118+
2119+
if (auto ad = dyn_cast<AccessorDecl>(afd))
2120+
return ad->getStorage()->isInvalid();
2121+
2122+
if (auto *ctor = dyn_cast<ConstructorDecl>(afd)) {
2123+
if (ctor->hasStubImplementation())
2124+
return true;
2125+
}
2126+
return false;
2127+
});
2128+
21452129
if (methods.size() < 2)
21462130
continue;
21472131

0 commit comments

Comments
 (0)