mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[ModuleInterfaces] Warn emitting an interface in -swift-version 4[.2]
If the project ever drops Swift 4 mode or Swift 4.2 mode, that would break modules using those modes in their interface, so put an unsilenceable warning in for using those modes to nudge interface emitters to Swift 5. rdar://problem/47792595
This commit is contained in:
@@ -358,12 +358,22 @@ static bool printAsObjCIfNeeded(StringRef outputPath, ModuleDecl *M,
|
||||
/// \returns true if there were any errors
|
||||
///
|
||||
/// \see swift::emitParseableInterface
|
||||
static bool printParseableInterfaceIfNeeded(StringRef outputPath,
|
||||
ParseableInterfaceOptions const &Opts,
|
||||
ModuleDecl *M) {
|
||||
static bool
|
||||
printParseableInterfaceIfNeeded(StringRef outputPath,
|
||||
ParseableInterfaceOptions const &Opts,
|
||||
LangOptions const &LangOpts,
|
||||
ModuleDecl *M) {
|
||||
if (outputPath.empty())
|
||||
return false;
|
||||
return withOutputFile(M->getDiags(), outputPath,
|
||||
|
||||
DiagnosticEngine &diags = M->getDiags();
|
||||
if (!LangOpts.isSwiftVersionAtLeast(5)) {
|
||||
assert(LangOpts.isSwiftVersionAtLeast(4));
|
||||
diags.diagnose(SourceLoc(),
|
||||
diag::warn_unsupported_module_interface_swift_version,
|
||||
LangOpts.isSwiftVersionAtLeast(4, 2) ? "4.2" : "4");
|
||||
}
|
||||
return withOutputFile(diags, outputPath,
|
||||
[M, Opts](raw_ostream &out) -> bool {
|
||||
return swift::emitParseableInterface(out, Opts, M);
|
||||
});
|
||||
@@ -921,6 +931,7 @@ static bool emitAnyWholeModulePostTypeCheckSupplementaryOutputs(
|
||||
hadAnyError |= printParseableInterfaceIfNeeded(
|
||||
Invocation.getParseableInterfaceOutputPathForWholeModule(),
|
||||
Invocation.getParseableInterfaceOptions(),
|
||||
Invocation.getLangOptions(),
|
||||
Instance.getMainModule());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user