[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

@@ -2831,6 +2831,18 @@ void Serializer::writeDecl(const Decl *D) {
auto underlying = typeAlias->getUnderlyingTypeLoc().getType();
SmallVector<TypeID, 2> dependencies;
for (Type dep : collectDependenciesFromType(underlying->getCanonicalType()))
dependencies.push_back(addTypeRef(dep));
for (Requirement req : typeAlias->getGenericRequirements()) {
for (Type dep : collectDependenciesFromType(req.getFirstType()))
dependencies.push_back(addTypeRef(dep));
if (req.getKind() != RequirementKind::Layout)
for (Type dep : collectDependenciesFromType(req.getSecondType()))
dependencies.push_back(addTypeRef(dep));
}
uint8_t rawAccessLevel =
getRawStableAccessLevel(typeAlias->getFormalAccess());
@@ -2843,7 +2855,8 @@ void Serializer::writeDecl(const Decl *D) {
typeAlias->isImplicit(),
addGenericEnvironmentRef(
typeAlias->getGenericEnvironment()),
rawAccessLevel);
rawAccessLevel,
dependencies);
writeGenericParams(typeAlias->getGenericParams());
break;
}