[Serialization] Recover if a typealias's underlying type is broken (#12979)

We could handle a typealias itself disappearing, but not if the
typealias was okay but the underlying type wasn't. This came up in
real Swift 3/4 mix-and-match code.

rdar://problem/34940079
This commit is contained in:
Jordan Rose
2017-11-16 19:31:13 -08:00
committed by GitHub
parent dbce0409ce
commit ac6fd7214e
4 changed files with 42 additions and 6 deletions

View File

@@ -2514,11 +2514,22 @@ ModuleFile::getDeclCheckedImpl(DeclID DID, Optional<DeclContext *> ForcedContext
bool isImplicit;
GenericEnvironmentID genericEnvID;
uint8_t rawAccessLevel;
ArrayRef<uint64_t> dependencyIDs;
decls_block::TypeAliasLayout::readRecord(scratch, nameID, contextID,
underlyingTypeID, interfaceTypeID,
isImplicit, genericEnvID,
rawAccessLevel);
rawAccessLevel, dependencyIDs);
Identifier name = getIdentifier(nameID);
for (TypeID dependencyID : dependencyIDs) {
auto dependency = getTypeChecked(dependencyID);
if (!dependency) {
return llvm::make_error<TypeError>(
name, takeErrorInfo(dependency.takeError()));
}
}
auto DC = ForcedContext ? *ForcedContext : getDeclContext(contextID);
@@ -2526,8 +2537,7 @@ ModuleFile::getDeclCheckedImpl(DeclID DID, Optional<DeclContext *> ForcedContext
if (declOrOffset.isComplete())
return declOrOffset;
auto alias = createDecl<TypeAliasDecl>(SourceLoc(), SourceLoc(),
getIdentifier(nameID),
auto alias = createDecl<TypeAliasDecl>(SourceLoc(), SourceLoc(), name,
SourceLoc(), genericParams, DC);
declOrOffset = alias;