@@ -1720,9 +1720,9 @@ void ModuleDecl::getImportedModules(SmallVectorImpl<ImportedModule> &modules,
1720
1720
FORWARD (getImportedModules, (modules, filter));
1721
1721
}
1722
1722
1723
- void ModuleDecl::getMissingImportedModules (
1723
+ void ModuleDecl::getImplicitImportsForModuleInterface (
1724
1724
SmallVectorImpl<ImportedModule> &imports) const {
1725
- FORWARD (getMissingImportedModules , (imports));
1725
+ FORWARD (getImplicitImportsForModuleInterface , (imports));
1726
1726
}
1727
1727
1728
1728
const llvm::DenseMap<const clang::Module *, ModuleDecl *> &
@@ -1811,9 +1811,9 @@ SourceFile::getImportedModules(SmallVectorImpl<ImportedModule> &modules,
1811
1811
}
1812
1812
}
1813
1813
1814
- void SourceFile::getMissingImportedModules (
1814
+ void SourceFile::getImplicitImportsForModuleInterface (
1815
1815
SmallVectorImpl<ImportedModule> &modules) const {
1816
- for (auto module : MissingImportedModules )
1816
+ for (auto module : ImplicitImportsForModuleInterface )
1817
1817
modules.push_back (module );
1818
1818
}
1819
1819
@@ -2817,13 +2817,13 @@ bool SourceFile::hasImportsWithFlag(ImportFlags flag) const {
2817
2817
ctx.evaluator , HasImportsMatchingFlagRequest{mutableThis, flag}, false );
2818
2818
}
2819
2819
2820
- ImportFlags SourceFile::getImportFlags (const ModuleDecl *module ) const {
2821
- unsigned flags = 0x0 ;
2820
+ void SourceFile::forEachImportOfModule (
2821
+ const ModuleDecl *module ,
2822
+ llvm::function_ref<void (AttributedImport<ImportedModule> &)> callback) {
2822
2823
for (auto import : *Imports) {
2823
2824
if (import .module .importedModule == module )
2824
- flags |= import . options . toRaw ( );
2825
+ callback ( import );
2825
2826
}
2826
- return ImportFlags (flags);
2827
2827
}
2828
2828
2829
2829
bool SourceFile::hasTestableOrPrivateImport (
@@ -4093,62 +4093,3 @@ version::Version ModuleDecl::getLanguageVersionBuiltWith() const {
4093
4093
4094
4094
return version::Version ();
4095
4095
}
4096
-
4097
- bool swift::diagnoseMissingImportForMember (const ValueDecl *decl,
4098
- const DeclContext *dc,
4099
- SourceLoc loc) {
4100
- if (decl->findImport (dc))
4101
- return false ;
4102
-
4103
- auto &ctx = dc->getASTContext ();
4104
- auto definingModule = decl->getModuleContext ();
4105
- ctx.Diags .diagnose (loc, diag::candidate_from_missing_import,
4106
- decl->getDescriptiveKind (), decl->getName (),
4107
- definingModule);
4108
-
4109
- SourceLoc bestLoc =
4110
- ctx.Diags .getBestAddImportFixItLoc (decl, dc->getParentSourceFile ());
4111
- if (!bestLoc.isValid ())
4112
- return false ;
4113
-
4114
- llvm::SmallString<64 > importText;
4115
-
4116
- // Check other source files for import flags that should be applied to the
4117
- // fix-it for consistency with the rest of the imports in the module.
4118
- auto parentModule = dc->getParentModule ();
4119
- OptionSet<ImportFlags> flags;
4120
- for (auto file : parentModule->getFiles ()) {
4121
- if (auto sf = dyn_cast<SourceFile>(file))
4122
- flags |= sf->getImportFlags (definingModule);
4123
- }
4124
-
4125
- if (flags.contains (ImportFlags::Exported) ||
4126
- parentModule->isClangOverlayOf (definingModule))
4127
- importText += " @_exported " ;
4128
- if (flags.contains (ImportFlags::ImplementationOnly))
4129
- importText += " @_implementationOnly " ;
4130
- if (flags.contains (ImportFlags::WeakLinked))
4131
- importText += " @_weakLinked " ;
4132
- if (flags.contains (ImportFlags::SPIOnly))
4133
- importText += " @_spiOnly " ;
4134
-
4135
- // FIXME: Access level should be considered, too.
4136
-
4137
- // @_spi imports.
4138
- if (decl->isSPI ()) {
4139
- auto spiGroups = decl->getSPIGroups ();
4140
- if (!spiGroups.empty ()) {
4141
- importText += " @_spi(" ;
4142
- importText += spiGroups[0 ].str ();
4143
- importText += " ) " ;
4144
- }
4145
- }
4146
-
4147
- importText += " import " ;
4148
- importText += definingModule->getName ().str ();
4149
- importText += " \n " ;
4150
- ctx.Diags .diagnose (bestLoc, diag::candidate_add_import, definingModule)
4151
- .fixItInsert (bestLoc, importText);
4152
-
4153
- return true ;
4154
- }
0 commit comments