Sema: Only add implicit imports to module interface during resilience typechecking.

Previously, implicit imports were also being added to the module interface during override checking (without any diagnostic).

Additionally, correct the structure of the import which contained an extra, duplicated path component. It would be diagnosed as a scoped import and written into the interface like this:

```
import UIKit/*.UIKit*/
```

Resolves rdar://104935794
This commit is contained in:
Allan Shortlidge
2023-03-12 23:08:27 -07:00
parent 6b0c22c334
commit b36b946e97
3 changed files with 92 additions and 24 deletions

View File

@@ -3115,21 +3115,6 @@ RestrictedImportKind SourceFile::getRestrictedImportKind(const ModuleDecl *modul
if (imports.isImportedBy(module, getParentModule()))
return RestrictedImportKind::None;
if (importKind == RestrictedImportKind::MissingImport &&
(module->getLibraryLevel() == LibraryLevel::API ||
getParentModule()->getLibraryLevel() != LibraryLevel::API)) {
// Hack to fix swiftinterfaces in case of missing imports.
// We can get rid of this logic when we don't leak the use of non-locally
// imported things in API.
ImportPath::Element pathElement = {module->getName(), SourceLoc()};
auto pathArray = getASTContext().AllocateCopy(
llvm::makeArrayRef(pathElement));
auto missingImport = ImportedModule(
ImportPath::Access(pathArray),
const_cast<ModuleDecl *>(module));
addMissingImportedModule(missingImport);
}
return importKind;
}