Skip to content

Commit 046f17f

Browse files
committed
[AST] Move the empty module assertion
Start asserting in `ModuleDecl::getFiles` that the module is either non-empty or has failed to load. This ensures that module loading doesn't attempt to query the module's files until the ModuleFile has been installed.
1 parent 6477cc6 commit 046f17f

File tree

2 files changed

+1
-5
lines changed

2 files changed

+1
-5
lines changed

include/swift/AST/Module.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ class ModuleDecl : public DeclContext, public TypeDecl {
363363
ArrayRef<ImplicitImport> getImplicitImports() const;
364364

365365
ArrayRef<FileUnit *> getFiles() {
366+
assert(!Files.empty() || failedToLoad());
366367
return Files;
367368
}
368369
ArrayRef<const FileUnit *> getFiles() const {

lib/AST/ASTContext.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,11 +1515,6 @@ void ASTContext::verifyAllLoadedModules() const {
15151515
FrontendStatsTracer tracer(Stats, "verify-all-loaded-modules");
15161516
for (auto &loader : getImpl().ModuleLoaders)
15171517
loader->verifyAllModules();
1518-
1519-
for (auto &topLevelModulePair : LoadedModules) {
1520-
ModuleDecl *M = topLevelModulePair.second;
1521-
assert(!M->getFiles().empty() || M->failedToLoad());
1522-
}
15231518
#endif
15241519
}
15251520

0 commit comments

Comments
 (0)