Skip to content

Commit 95d6ddf

Browse files
committed
NCGenerics: handle failure to load stdlib
The stdlib module can end up being a non-null ModuleDecl that contains no files, due to a failure to load the stdlib. In such an unusual case, fall-back to synthesizing Copyable/Escapable into the Builtin module so that Sema can proceed. rdar://129092011 (cherry picked from commit b02b94c)
1 parent b5f1c07 commit 95d6ddf

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/AST/ASTContext.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,6 +1255,14 @@ ASTContext::synthesizeInvertibleProtocolDecl(InvertibleProtocolKind ip) const {
12551255
return proto;
12561256

12571257
ModuleDecl *stdlib = getStdlibModule();
1258+
if (stdlib && stdlib->failedToLoad()) {
1259+
stdlib = nullptr; // Use the Builtin module instead.
1260+
1261+
// Ensure we emitted an error diagnostic!
1262+
if (!Diags.hadAnyError())
1263+
Diags.diagnose(SourceLoc(), diag::serialization_load_failed, "Swift");
1264+
}
1265+
12581266
FileUnit *file = nullptr;
12591267
if (stdlib) {
12601268
file = &stdlib->getFiles()[0]->getOrCreateSynthesizedFile();

0 commit comments

Comments
 (0)