@@ -159,6 +159,10 @@ class SourceFile final : public FileUnit {
159159 // / The highest access level of declarations referencing each import.
160160 llvm::DenseMap<const ModuleDecl *, AccessLevel> ImportsUseAccessLevel;
161161
162+ // / Imports that should be printed in the module interface even though they
163+ // / were not written in the source file.
164+ llvm::SmallDenseSet<ImportedModule> ImplicitImportsForModuleInterface;
165+
162166 // / A unique identifier representing this file; used to mark private decls
163167 // / within the file to keep them from conflicting with other files in the
164168 // / same module.
@@ -510,12 +514,20 @@ class SourceFile final : public FileUnit {
510514
511515 SWIFT_DEBUG_DUMPER (dumpSeparatelyImportedOverlays());
512516
513- llvm::SmallDenseSet<ImportedModule> MissingImportedModules;
514-
515- void addMissingImportedModule (ImportedModule module ) const {
516- const_cast <SourceFile *>(this )->MissingImportedModules .insert (module );
517+ // / Record an import that should be printed in the module interface even
518+ // / though it was not written in the source file. These imports are needed in
519+ // / Swift 5 mode to preserve the integrity of swiftinterface files when code
520+ // / publicly use declarations from modules that were \c `@_implementationOnly`
521+ // / imported in other source files.
522+ void addImplicitImportForModuleInterface (ImportedModule module ) {
523+ ImplicitImportsForModuleInterface.insert (module );
517524 }
518525
526+ // / Gather implicit imports that should printed in swiftinterfaces for
527+ // / compatibility with code in some Swift 5 modules.
528+ void getImplicitImportsForModuleInterface (
529+ SmallVectorImpl<ImportedModule> &imports) const override ;
530+
519531 // / Record the source range info for a parsed \c #if clause.
520532 void recordIfConfigClauseRangeInfo (const IfConfigClauseRangeInfo &range);
521533
@@ -527,10 +539,10 @@ class SourceFile final : public FileUnit {
527539 ArrayRef<IfConfigClauseRangeInfo>
528540 getIfConfigClausesWithin (SourceRange outer) const ;
529541
530- void getMissingImportedModules (
531- SmallVectorImpl<ImportedModule> &imports) const override ;
532-
542+ // / Record visible declarations for use in code completion and refactoring.
533543 void cacheVisibleDecls (SmallVectorImpl<ValueDecl *> &&globals) const ;
544+
545+ // / Retrieve visible declarations for use in code completion and refactoring.
534546 const SmallVectorImpl<ValueDecl *> &getCachedVisibleDecls () const ;
535547
536548 virtual void lookupValue (DeclName name, NLKind lookupKind,
0 commit comments