mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Diagnose modules with circular dependencies (#16075)
This can't arise from a clean build, but it can happen if you have products lingering in a search path and then either rebuild one of the modules in the cycle, or change the search paths. The way this is implemented is for each module to track whether its imports have all been resolved. If, when loading a module, one of its dependencies hasn't resolved all of its imports yet, then we know there's a cycle. This doesn't produce the best diagnostics, but it's hard to get into this state in the first place, so that's probably okay. https://bugs.swift.org/browse/SR-7483
This commit is contained in:
@@ -206,6 +206,7 @@ private:
|
||||
unsigned TestingEnabled : 1;
|
||||
unsigned FailedToLoad : 1;
|
||||
unsigned ResilienceStrategy : 1;
|
||||
unsigned HasResolvedImports : 1;
|
||||
} Flags;
|
||||
|
||||
ModuleDecl(Identifier name, ASTContext &ctx);
|
||||
@@ -257,6 +258,13 @@ public:
|
||||
Flags.FailedToLoad = failed;
|
||||
}
|
||||
|
||||
bool hasResolvedImports() const {
|
||||
return Flags.HasResolvedImports;
|
||||
}
|
||||
void setHasResolvedImports() {
|
||||
Flags.HasResolvedImports = true;
|
||||
}
|
||||
|
||||
ResilienceStrategy getResilienceStrategy() const {
|
||||
return ResilienceStrategy(Flags.ResilienceStrategy);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user