Frontend: Really allow any experimental feature when compiling a module interface.

The fix for https://github.com/apple/swift/pull/72632 was not sufficient
because when modules are built from textual interface that happens in a
sub-invocation which does not have typecheck-from-interface or
compile-from-interface requested action. Instead of checking a requested
action, set a language option to control whether non-production experimental
features are allowed.

Resolves rdar://125561443
This commit is contained in:
Allan Shortlidge
2024-03-28 13:28:49 -07:00
parent 233c1675cf
commit 12fccfc4e0
6 changed files with 57 additions and 9 deletions

View File

@@ -872,17 +872,14 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
// If this is a known experimental feature, allow it in +Asserts
// (non-release) builds for testing purposes.
if (auto feature = getExperimentalFeature(value)) {
#ifdef NDEBUG
if (!buildingFromInterface && !isFeatureAvailableInProduction(*feature)) {
if (Opts.RestrictNonProductionExperimentalFeatures &&
!isFeatureAvailableInProduction(*feature)) {
Diags.diagnose(SourceLoc(), diag::experimental_not_supported_in_production,
A->getValue());
HadError = true;
} else {
Opts.enableFeature(*feature);
}
#else
Opts.enableFeature(*feature);
#endif
if (*feature == Feature::NoncopyableGenerics2)
Opts.enableFeature(Feature::NoncopyableGenerics);