mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Serialization] Recover from deserializing an enum from a missing module
rdar://problem/58022345
This commit is contained in:
@@ -1889,14 +1889,25 @@ DeclContext *ModuleFile::getLocalDeclContext(LocalDeclContextID DCID) {
|
||||
}
|
||||
|
||||
DeclContext *ModuleFile::getDeclContext(DeclContextID DCID) {
|
||||
auto deserialized = getDeclContextChecked(DCID);
|
||||
if (!deserialized) {
|
||||
fatal(deserialized.takeError());
|
||||
}
|
||||
return deserialized.get();
|
||||
}
|
||||
|
||||
Expected<DeclContext *> ModuleFile::getDeclContextChecked(DeclContextID DCID) {
|
||||
if (!DCID)
|
||||
return FileContext;
|
||||
|
||||
if (Optional<LocalDeclContextID> contextID = DCID.getAsLocalDeclContextID())
|
||||
return getLocalDeclContext(contextID.getValue());
|
||||
|
||||
auto D = getDecl(DCID.getAsDeclID().getValue());
|
||||
auto deserialized = getDeclChecked(DCID.getAsDeclID().getValue());
|
||||
if (!deserialized)
|
||||
return deserialized.takeError();
|
||||
|
||||
auto D = deserialized.get();
|
||||
if (auto GTD = dyn_cast<GenericTypeDecl>(D))
|
||||
return GTD;
|
||||
if (auto ED = dyn_cast<ExtensionDecl>(D))
|
||||
@@ -3496,7 +3507,6 @@ public:
|
||||
numConformances, numInherited,
|
||||
rawInheritedAndDependencyIDs);
|
||||
|
||||
auto DC = MF.getDeclContext(contextID);
|
||||
if (declOrOffset.isComplete())
|
||||
return declOrOffset;
|
||||
|
||||
@@ -3510,6 +3520,11 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
auto DCOrError = MF.getDeclContextChecked(contextID);
|
||||
if (!DCOrError)
|
||||
return DCOrError.takeError();
|
||||
auto DC = DCOrError.get();
|
||||
|
||||
auto genericParams = MF.maybeReadGenericParams(DC);
|
||||
if (declOrOffset.isComplete())
|
||||
return declOrOffset;
|
||||
|
||||
Reference in New Issue
Block a user