Frontend: Enable @_spiOnly by default in Swift 6

Enabling `@_spiOnly` also enables stronger type-checking of SPI decls.
As this could be source breaking, it has always been opt-in. Turn it on
by default in Swift 6 mode where the stronger type-checking will also
become expected.

At the same time, disable the old alternative to `@_spiOnly` which was
designed to be compatible with old compilers. Any user of that feature
should move to `@_spiOnly` or `package import` instead.
This commit is contained in:
Alexis Laferrière
2024-03-13 20:53:00 -07:00
parent e1c04c9d33
commit fb59f1fb11
4 changed files with 26 additions and 0 deletions

View File

@@ -3337,6 +3337,17 @@ bool CompilerInvocation::parseArgs(
}
}
// With Swift 6, enable @_spiOnly by default and forbid the old version.
// This also enables proper error reporting of ioi references from spi decls.
if (LangOpts.EffectiveLanguageVersion.isVersionAtLeast(6)) {
LangOpts.EnableSPIOnlyImports = true;
if (ParsedArgs.hasArg(OPT_experimental_spi_imports)) {
Diags.diagnose(SourceLoc(), diag::error_old_spi_only_import_unsupported);
return true;
}
}
return false;
}