mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Clang Importer] Do not rely on being able to always import Foundation on-demand
When importing Clang types. This is not an option with Explicit Module Builds. If the module being built does not (directly or transitively) depend on `Foundation`, then attempting to load it will produce an error because Implicit module loading is no longer allowed.. This change addresses a small number of cases where ClangImporter relies on being able to load `Foundation` on-demand: - When importing a single Decl from a clang module, we check whether it has certain conformances by checking all extensions of the NominalTypeDecl of the Decl in question, to see if any of the extensions contain the conformance we are looking for, but we only check extensions whose parent module is either the original module of the NominalTypeDecl or the overlay module of the NominalTypeDecl or Foundation. It seems that we do not need to actually import `Foundation` here, just checking the module Identifier should be sufficient. - In `maybeImportNSErrorOutParameter`, change the behavior to have an exit condition based on whether `Foundation` can be imported, before attempting to load it. - When checking whether or not we are allowed to bridge an Objective-C type, it also looks sufficient the query whether or not `Foundation` *can* be imported, without loading it.
This commit is contained in:
@@ -1363,6 +1363,10 @@ bool ModuleDecl::isOnoneSupportModule() const {
|
||||
return !getParent() && getName().str() == SWIFT_ONONE_SUPPORT;
|
||||
}
|
||||
|
||||
bool ModuleDecl::isFoundationModule() const {
|
||||
return !getParent() && getName() == getASTContext().Id_Foundation;
|
||||
}
|
||||
|
||||
bool ModuleDecl::isBuiltinModule() const {
|
||||
return this == getASTContext().TheBuiltinModule;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user