mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Serialization] Drop extensions whose requirements are missing types (#17488)
If, for whatever reason, a type used in an extension's generic requirements is missing, just drop the whole extension. This isn't wonderful recovery, but in practice nothing should be able to use the extension anyway, since the relevant type in question is missing. ...Okay, that's not quite true; there could, for example, be inlinable code that references one of these methods. However, that (1) isn't worse than the behavior for any other inlinable code (which doesn't yet attempt to recover from missing declarations), and (2) is still a strict improvement over the current situation, where we will eagerly abort the compiler trying to load the extension in the first place. rdar://problem/40956460
This commit is contained in:
@@ -2698,10 +2698,12 @@ void Serializer::writeDecl(const Decl *D) {
|
||||
inheritedAndDependencyTypes.push_back(addTypeRef(inherited.getType()));
|
||||
size_t numInherited = inheritedAndDependencyTypes.size();
|
||||
|
||||
// FIXME: Figure out what to do with requirements and such, which the
|
||||
// extension also depends on. Right now just do what is safe to drop, which
|
||||
// is the base declaration.
|
||||
auto dependencies = collectDependenciesFromType(baseTy);
|
||||
llvm::SmallSetVector<Type, 4> dependencies;
|
||||
collectDependenciesFromType(dependencies, baseTy, /*excluding*/nullptr);
|
||||
for (Requirement req : extension->getGenericRequirements()) {
|
||||
collectDependenciesFromRequirement(dependencies, req,
|
||||
/*excluding*/nullptr);
|
||||
}
|
||||
for (auto dependencyTy : dependencies)
|
||||
inheritedAndDependencyTypes.push_back(addTypeRef(dependencyTy));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user