@@ -1014,6 +1014,21 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
1014
1014
Opts.EnableExperimentalStringProcessing = true ;
1015
1015
}
1016
1016
1017
+ auto enableUpcomingFeature = [&Opts, &Diags](Feature feature) -> bool {
1018
+ // Check if this feature was introduced already in this language version.
1019
+ if (auto firstVersion = getFeatureLanguageVersion (feature)) {
1020
+ if (Opts.isSwiftVersionAtLeast (*firstVersion)) {
1021
+ Diags.diagnose (SourceLoc (), diag::error_upcoming_feature_on_by_default,
1022
+ getFeatureName (feature), *firstVersion);
1023
+ return true ;
1024
+ }
1025
+ }
1026
+
1027
+ Opts.enableFeature (feature);
1028
+ return false ;
1029
+ };
1030
+
1031
+ // Enable experimental features.
1017
1032
for (const Arg *A : Args.filtered (OPT_enable_experimental_feature)) {
1018
1033
// Allow StrictConcurrency to have a value that corresponds to the
1019
1034
// -strict-concurrency=<blah> settings.
@@ -1040,12 +1055,14 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
1040
1055
} else {
1041
1056
Opts.enableFeature (*feature);
1042
1057
}
1058
+ }
1043
1059
1044
- if (*feature == Feature::NoncopyableGenerics2)
1045
- Opts.enableFeature (Feature::NoncopyableGenerics);
1046
-
1047
- if (*feature == Feature::IsolatedAny2)
1048
- Opts.enableFeature (Feature::IsolatedAny);
1060
+ // For compatibility, upcoming features can be enabled with the
1061
+ // -enable-experimental-feature flag too since the feature may have
1062
+ // graduated from being experimental.
1063
+ if (auto feature = getUpcomingFeature (value)) {
1064
+ if (enableUpcomingFeature (*feature))
1065
+ HadError = true ;
1049
1066
}
1050
1067
1051
1068
// Hack: In order to support using availability macros in SPM packages, we
@@ -1062,24 +1079,15 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
1062
1079
}
1063
1080
}
1064
1081
1065
- // Map historical flags over to future features.
1082
+ // Enable upcoming features.
1066
1083
for (const Arg *A : Args.filtered (OPT_enable_upcoming_feature)) {
1067
1084
// Ignore unknown features.
1068
1085
auto feature = getUpcomingFeature (A->getValue ());
1069
1086
if (!feature)
1070
1087
continue ;
1071
1088
1072
- // Check if this feature was introduced already in this language version.
1073
- if (auto firstVersion = getFeatureLanguageVersion (*feature)) {
1074
- if (Opts.isSwiftVersionAtLeast (*firstVersion)) {
1075
- Diags.diagnose (SourceLoc (), diag::error_upcoming_feature_on_by_default,
1076
- A->getValue (), *firstVersion);
1077
- continue ;
1078
- }
1079
- }
1080
-
1081
- // Add the feature.
1082
- Opts.enableFeature (*feature);
1089
+ if (enableUpcomingFeature (*feature))
1090
+ HadError = true ;
1083
1091
}
1084
1092
1085
1093
// Map historical flags over to experimental features. We do this for all
0 commit comments