Serialization: Recover from errors under loadObjCMethods

The diagnostics about unintended override of Objective-C methods
deserializes more decls than strictly necessary. Any of these could
trigger a deserialization failure if they rely on missing dependencies.
Simply ignore methods failing to deserialize instead of crashing.

We could do better here as this logic may ignore methods that are actually
colliding. Instead we could put more information in the lookup table to
avoid the need for fully deserializing the decl.

rdar://138764733
This commit is contained in:
Alexis Laferrière
2024-10-29 13:00:46 -07:00
parent 3aed0950aa
commit 9d090c8aab
2 changed files with 46 additions and 1 deletions

View File

@@ -712,8 +712,15 @@ void ModuleFile::loadObjCMethods(
continue;
// Deserialize the method and add it to the list.
// Drop methods with errors.
auto funcOrError = getDeclChecked(std::get<2>(result));
if (!funcOrError) {
diagnoseAndConsumeError(funcOrError.takeError());
continue;
}
if (auto func = dyn_cast_or_null<AbstractFunctionDecl>(
getDecl(std::get<2>(result)))) {
funcOrError.get())) {
methods.push_back(func);
}
}