Merge pull request #74199 from cachemeifyoucan/eng/PR-128876895

[ScanDependencies] Make sure `canImport` resolution agrees with `import`
This commit is contained in:
Steven Wu
2024-06-18 09:14:19 -07:00
committed by GitHub
16 changed files with 109 additions and 53 deletions

View File

@@ -1109,7 +1109,7 @@ public:
///
/// Note that even if this check succeeds, errors may still occur if the
/// module is loaded in full.
bool canImportModuleImpl(ImportPath::Module ModulePath,
bool canImportModuleImpl(ImportPath::Module ModulePath, SourceLoc loc,
llvm::VersionTuple version, bool underlyingVersion,
bool updateFailingList,
llvm::VersionTuple &foundVersion) const;
@@ -1146,7 +1146,7 @@ public:
///
/// Note that even if this check succeeds, errors may still occur if the
/// module is loaded in full.
bool canImportModule(ImportPath::Module ModulePath,
bool canImportModule(ImportPath::Module ModulePath, SourceLoc loc,
llvm::VersionTuple version = llvm::VersionTuple(),
bool underlyingVersion = false);

View File

@@ -830,6 +830,9 @@ ERROR(serialization_failed,none,
"serialization of module %0 failed due to the errors above",
(const ModuleDecl *))
WARNING(can_import_invalid_swiftmodule,none,
"canImport() evaluated to false due to invalid swiftmodule: %0", (StringRef))
ERROR(serialization_load_failed,Fatal,
"failed to load module '%0'", (StringRef))
ERROR(module_interface_build_failed,Fatal,

View File

@@ -287,7 +287,7 @@ public:
///
/// If a non-null \p versionInfo is provided, the module version will be
/// parsed and populated.
virtual bool canImportModule(ImportPath::Module named,
virtual bool canImportModule(ImportPath::Module named, SourceLoc loc,
ModuleVersionInfo *versionInfo,
bool isTestableImport = false) = 0;

View File

@@ -227,7 +227,7 @@ public:
///
/// If a non-null \p versionInfo is provided, the module version will be
/// parsed and populated.
virtual bool canImportModule(ImportPath::Module named,
virtual bool canImportModule(ImportPath::Module named, SourceLoc loc,
ModuleVersionInfo *versionInfo,
bool isTestableImport = false) override;

View File

@@ -163,7 +163,7 @@ class ExplicitSwiftModuleLoader: public SerializedModuleLoaderBase {
bool SkipBuildingInterface, bool IsFramework,
bool IsTestableDependencyLookup = false) override;
bool canImportModule(ImportPath::Module named,
bool canImportModule(ImportPath::Module named, SourceLoc loc,
ModuleVersionInfo *versionInfo,
bool isTestableDependencyLookup = false) override;
@@ -212,7 +212,7 @@ class ExplicitCASModuleLoader : public SerializedModuleLoaderBase {
bool SkipBuildingInterface, bool IsFramework,
bool IsTestableDependencyLookup = false) override;
bool canImportModule(ImportPath::Module named,
bool canImportModule(ImportPath::Module named, SourceLoc loc,
ModuleVersionInfo *versionInfo,
bool isTestableDependencyLookup = false) override;

View File

@@ -59,9 +59,10 @@ public:
///
/// If a non-null \p versionInfo is provided, the module version will be
/// parsed and populated.
virtual bool canImportModule(ImportPath::Module named,
ModuleVersionInfo *versionInfo,
bool isTestableDependencyLookup = false) override;
virtual bool
canImportModule(ImportPath::Module named, SourceLoc loc,
ModuleVersionInfo *versionInfo,
bool isTestableDependencyLookup = false) override;
/// Import a module with the given module path.
///

View File

@@ -209,9 +209,10 @@ public:
///
/// If a non-null \p versionInfo is provided, the module version will be
/// parsed and populated.
virtual bool canImportModule(ImportPath::Module named,
ModuleVersionInfo *versionInfo,
bool isTestableDependencyLookup = false) override;
virtual bool
canImportModule(ImportPath::Module named, SourceLoc loc,
ModuleVersionInfo *versionInfo,
bool isTestableDependencyLookup = false) override;
/// Import a module with the given module path.
///
@@ -339,7 +340,7 @@ class MemoryBufferSerializedModuleLoader : public SerializedModuleLoaderBase {
public:
virtual ~MemoryBufferSerializedModuleLoader();
bool canImportModule(ImportPath::Module named,
bool canImportModule(ImportPath::Module named, SourceLoc loc,
ModuleVersionInfo *versionInfo,
bool isTestableDependencyLookup = false) override;