mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user