[ModuleInterface] Print the public keyword on imports in Swift 6 mode

If the access-level on imports proposal is accepted as written, all
imports printed in swiftinterfaces will be `public`. Whether or not we
require the explicit `public` keyword in Swift 6 mode, printing it will
have no downside. It also goes along with the mentality that
swiftinterfaces should be more explicit than implicit.

rdar://115455383
This commit is contained in:
Alexis Laferrière
2023-09-13 16:15:12 -07:00
parent 33db18654e
commit 3496a74fd9
2 changed files with 22 additions and 0 deletions

View File

@@ -348,6 +348,10 @@ static void printImports(raw_ostream &out,
out << "@_spi(" << spiName << ") ";
}
if (M->getASTContext().LangOpts.isSwiftVersionAtLeast(6)) {
out << "public ";
}
out << "import ";
if (Opts.AliasModuleNames &&
AliasModuleNamesTargets.contains(importedModule->getName().str()))