Skip to content

Commit b02b94c

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
1 parent 846a861 commit b02b94c

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
@@ -1313,6 +1313,14 @@ ASTContext::synthesizeInvertibleProtocolDecl(InvertibleProtocolKind ip) const {
13131313
return proto;
13141314

13151315
ModuleDecl *stdlib = getStdlibModule();
1316+
if (stdlib && stdlib->failedToLoad()) {
1317+
stdlib = nullptr; // Use the Builtin module instead.
1318+
1319+
// Ensure we emitted an error diagnostic!
1320+
if (!Diags.hadAnyError())
1321+
Diags.diagnose(SourceLoc(), diag::serialization_load_failed, "Swift");
1322+
}
1323+
13161324
FileUnit *file = nullptr;
13171325
if (stdlib) {
13181326
file = &stdlib->getFiles()[0]->getOrCreateSynthesizedFile();

0 commit comments

Comments
 (0)