Skip to content

Commit 085078d

Browse files
committed
[Feature] Rename Feature APIs from adoption to migration
1 parent 2a479ac commit 085078d

12 files changed

+44
-44
lines changed

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ GROUPED_WARNING(cannot_disable_feature_with_mode, StrictLanguageFeatures, none,
5959
"'%0' argument '%1' cannot specify a mode",
6060
(StringRef, StringRef))
6161

62-
GROUPED_WARNING(feature_does_not_support_adoption_mode, StrictLanguageFeatures,
62+
GROUPED_WARNING(feature_does_not_support_migration_mode, StrictLanguageFeatures,
6363
none,
64-
"feature '%0' does not support adoption mode",
64+
"feature '%0' does not support migration mode",
6565
(StringRef))
6666

6767
ERROR(error_unknown_library_level, none,

include/swift/Basic/Feature.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ struct Feature {
5757
/// Determine the in-source name of the given feature.
5858
llvm::StringRef getName() const;
5959

60-
/// Determine whether the given feature supports adoption mode.
61-
bool isAdoptable() const;
60+
/// Determine whether the given feature supports migration mode.
61+
bool isMigratable() const;
6262

6363
/// Determine whether this feature should be included in the
6464
/// module interface

include/swift/Basic/LangOptions.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ namespace swift {
830830

831831
/// A wrapper around the feature state enumeration.
832832
struct FeatureState {
833-
enum class Kind : uint8_t { Off, EnabledForAdoption, Enabled };
833+
enum class Kind : uint8_t { Off, EnabledForMigration, Enabled };
834834

835835
private:
836836
Feature feature;
@@ -843,9 +843,9 @@ namespace swift {
843843
/// Returns whether the feature is enabled.
844844
bool isEnabled() const;
845845

846-
/// Returns whether the feature is enabled in adoption mode. Should only
846+
/// Returns whether the feature is enabled in migration mode. Should only
847847
/// be called if the feature is known to support this mode.
848-
bool isEnabledForAdoption() const;
848+
bool isEnabledForMigration() const;
849849

850850
operator Kind() const { return state; }
851851
};
@@ -878,9 +878,9 @@ namespace swift {
878878
/// `false` if a feature by this name is not known.
879879
bool hasFeature(llvm::StringRef featureName) const;
880880

881-
/// Enables the given feature (enables in adoption mode if `forAdoption` is
882-
/// `true`).
883-
void enableFeature(Feature feature, bool forAdoption = false);
881+
/// Enables the given feature (enables in migration mode if `forMigration`
882+
/// is `true`).
883+
void enableFeature(Feature feature, bool forMigration = false);
884884

885885
/// Disables the given feature.
886886
void disableFeature(Feature feature);

lib/Basic/Feature.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ std::optional<unsigned> Feature::getLanguageVersion() const {
6969
}
7070
}
7171

72-
bool Feature::isAdoptable() const {
72+
bool Feature::isMigratable() const {
7373
switch (kind) {
7474
#define MIGRATABLE_UPCOMING_FEATURE(FeatureName, SENumber, Version)
7575
#define MIGRATABLE_EXPERIMENTAL_FEATURE(FeatureName, AvailableInProd)

lib/Basic/LangOptions.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,10 @@ bool LangOptions::FeatureState::isEnabled() const {
298298
return state == FeatureState::Kind::Enabled;
299299
}
300300

301-
bool LangOptions::FeatureState::isEnabledForAdoption() const {
302-
ASSERT(feature.isAdoptable() && "You forgot to make the feature adoptable!");
301+
bool LangOptions::FeatureState::isEnabledForMigration() const {
302+
ASSERT(feature.isMigratable() && "You forgot to make the feature migratable!");
303303

304-
return state == FeatureState::Kind::EnabledForAdoption;
304+
return state == FeatureState::Kind::EnabledForMigration;
305305
}
306306

307307
LangOptions::FeatureStateStorage::FeatureStateStorage()
@@ -357,10 +357,10 @@ bool LangOptions::hasFeature(llvm::StringRef featureName) const {
357357
return false;
358358
}
359359

360-
void LangOptions::enableFeature(Feature feature, bool forAdoption) {
361-
if (forAdoption) {
362-
ASSERT(feature.isAdoptable());
363-
featureStates.setState(feature, FeatureState::Kind::EnabledForAdoption);
360+
void LangOptions::enableFeature(Feature feature, bool forMigration) {
361+
if (forMigration) {
362+
ASSERT(feature.isMigratable());
363+
featureStates.setState(feature, FeatureState::Kind::EnabledForMigration);
364364
return;
365365
}
366366

lib/Basic/SupportedFeatures.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void printSupportedFeatures(llvm::raw_ostream &out) {
4848
auto printFeature = [&out](const Feature &feature) {
4949
out << " ";
5050
out << "{ \"name\": \"" << feature.getName() << "\"";
51-
if (feature.isAdoptable()) {
51+
if (feature.isMigratable()) {
5252
out << ", \"migratable\": true";
5353
}
5454
if (auto version = feature.getLanguageVersion()) {

lib/Frontend/CompilerInvocation.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -872,21 +872,21 @@ static bool ParseEnabledFeatureArgs(LangOptions &Opts, ArgList &Args,
872872

873873
if (featureMode) {
874874
if (isEnableFeatureFlag) {
875-
const auto isAdoptable = feature->isAdoptable();
875+
const auto isMigratable = feature->isMigratable();
876876

877877
// Diagnose an invalid mode.
878878
StringRef validModeName = "adoption";
879879
if (*featureMode != validModeName) {
880880
Diags.diagnose(SourceLoc(), diag::invalid_feature_mode, *featureMode,
881881
featureName,
882882
/*didYouMean=*/validModeName,
883-
/*showDidYouMean=*/isAdoptable);
883+
/*showDidYouMean=*/isMigratable);
884884
continue;
885885
}
886886

887-
if (!isAdoptable) {
887+
if (!isMigratable) {
888888
Diags.diagnose(SourceLoc(),
889-
diag::feature_does_not_support_adoption_mode,
889+
diag::feature_does_not_support_migration_mode,
890890
featureName);
891891
continue;
892892
}
@@ -904,7 +904,7 @@ static bool ParseEnabledFeatureArgs(LangOptions &Opts, ArgList &Args,
904904

905905
// Enable the feature if requested.
906906
if (isEnableFeatureFlag)
907-
Opts.enableFeature(*feature, /*forAdoption=*/featureMode.has_value());
907+
Opts.enableFeature(*feature, /*forMigration=*/featureMode.has_value());
908908
}
909909

910910
// Since pseudo-features don't have a boolean on/off state, process them in

lib/Sema/NonisolatedNonsendingByDefaultMigration.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void NonisolatedNonsendingByDefaultMigrationTarget::diagnose() const {
6060
const auto feature = Feature::NonisolatedNonsendingByDefault;
6161

6262
ASSERT(node);
63-
ASSERT(ctx.LangOpts.getFeatureState(feature).isEnabledForAdoption());
63+
ASSERT(ctx.LangOpts.getFeatureState(feature).isEnabledForMigration());
6464

6565
ValueDecl *decl = nullptr;
6666
ClosureExpr *closure = nullptr;

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4752,7 +4752,7 @@ ActorIsolation ActorIsolationChecker::determineClosureIsolation(
47524752
isolation = isolation.withPreconcurrency(preconcurrency);
47534753

47544754
if (ctx.LangOpts.getFeatureState(Feature::NonisolatedNonsendingByDefault)
4755-
.isEnabledForAdoption()) {
4755+
.isEnabledForMigration()) {
47564756
warnAboutNewNonisolatedAsyncExecutionBehavior(ctx, closure, isolation);
47574757
}
47584758

@@ -6260,7 +6260,7 @@ InferredActorIsolation ActorIsolationRequest::evaluate(Evaluator &evaluator,
62606260

62616261
auto &ctx = value->getASTContext();
62626262
if (ctx.LangOpts.getFeatureState(Feature::NonisolatedNonsendingByDefault)
6263-
.isEnabledForAdoption()) {
6263+
.isEnabledForMigration()) {
62646264
warnAboutNewNonisolatedAsyncExecutionBehavior(ctx, value,
62656265
inferredIsolation.isolation);
62666266
}

lib/Sema/TypeCheckType.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4246,7 +4246,7 @@ NeverNullType TypeResolver::resolveASTFunctionType(
42464246
isolation = FunctionTypeIsolation::forNonIsolated();
42474247
} else {
42484248
if (ctx.LangOpts.getFeatureState(Feature::NonisolatedNonsendingByDefault)
4249-
.isEnabledForAdoption()) {
4249+
.isEnabledForMigration()) {
42504250
// Diagnose only in the interface stage, which is run once.
42514251
if (inStage(TypeResolutionStage::Interface)) {
42524252
warnAboutNewNonisolatedAsyncExecutionBehavior(ctx, repr, isolation);
@@ -6572,7 +6572,7 @@ class ExistentialTypeSyntaxChecker : public ASTWalker {
65726572
// A missing `any` or `some` is always diagnosed if this feature not
65736573
// disabled.
65746574
auto featureState = ctx.LangOpts.getFeatureState(Feature::ExistentialAny);
6575-
if (featureState.isEnabled() || featureState.isEnabledForAdoption()) {
6575+
if (featureState.isEnabled() || featureState.isEnabledForMigration()) {
65766576
return true;
65776577
}
65786578

@@ -6665,10 +6665,10 @@ class ExistentialTypeSyntaxChecker : public ASTWalker {
66656665
/*isAlias=*/isa<TypeAliasDecl>(decl)));
66666666
}
66676667

6668-
// If `ExistentialAny` is enabled in adoption mode, warn unconditionally.
6668+
// If `ExistentialAny` is enabled in migration mode, warn unconditionally.
66696669
// Otherwise, warn until the feature's coming-of-age language mode.
66706670
const auto feature = Feature::ExistentialAny;
6671-
if (Ctx.LangOpts.getFeatureState(feature).isEnabledForAdoption()) {
6671+
if (Ctx.LangOpts.getFeatureState(feature).isEnabledForMigration()) {
66726672
diag->limitBehavior(DiagnosticBehavior::Warning);
66736673
} else {
66746674
diag->warnUntilSwiftVersion(feature.getLanguageVersion().value());

0 commit comments

Comments
 (0)