mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Serialization] Fix crashes when allowing compiler errors in modules
This commit is contained in:
@@ -1355,7 +1355,8 @@ void Serializer::writeASTBlockEntity(
|
||||
using namespace decls_block;
|
||||
|
||||
// The conformance must be complete, or we can't serialize it.
|
||||
assert(conformance->isComplete());
|
||||
assert(conformance->isComplete() ||
|
||||
getASTContext().LangOpts.AllowModuleWithCompilerErrors);
|
||||
assert(NormalConformancesToSerialize.hasRef(conformance));
|
||||
|
||||
auto protocol = conformance->getProtocol();
|
||||
@@ -1541,6 +1542,8 @@ static bool shouldSerializeMember(Decl *D) {
|
||||
case DeclKind::Extension:
|
||||
case DeclKind::Module:
|
||||
case DeclKind::PrecedenceGroup:
|
||||
if (D->getASTContext().LangOpts.AllowModuleWithCompilerErrors)
|
||||
return false;
|
||||
llvm_unreachable("decl should never be a member");
|
||||
|
||||
case DeclKind::MissingMember:
|
||||
@@ -5050,7 +5053,9 @@ static void collectInterestingNestedDeclarations(
|
||||
if (!nominalParent) {
|
||||
const DeclContext *DC = member->getDeclContext();
|
||||
nominalParent = DC->getSelfNominalTypeDecl();
|
||||
assert(nominalParent && "parent context is not a type or extension");
|
||||
assert(nominalParent ||
|
||||
nestedType->getASTContext().LangOpts.AllowModuleWithCompilerErrors &&
|
||||
"parent context is not a type or extension");
|
||||
}
|
||||
nestedTypeDecls[nestedType->getName()].push_back({
|
||||
S.addDeclRef(nominalParent),
|
||||
@@ -5115,8 +5120,10 @@ void Serializer::writeAST(ModuleOrSourceFile DC) {
|
||||
.push_back({ getKindForTable(D), addDeclRef(D) });
|
||||
} else if (auto ED = dyn_cast<ExtensionDecl>(D)) {
|
||||
const NominalTypeDecl *extendedNominal = ED->getExtendedNominal();
|
||||
extensionDecls[extendedNominal->getName()]
|
||||
.push_back({ extendedNominal, addDeclRef(D) });
|
||||
if (extendedNominal) {
|
||||
extensionDecls[extendedNominal->getName()]
|
||||
.push_back({ extendedNominal, addDeclRef(D) });
|
||||
}
|
||||
} else if (auto OD = dyn_cast<OperatorDecl>(D)) {
|
||||
operatorDecls[OD->getName()]
|
||||
.push_back({ getStableFixity(OD->getFixity()), addDeclRef(D) });
|
||||
|
||||
Reference in New Issue
Block a user