Skip to content

Commit 61c8e70

Browse files
committed
[Feature] Rename Feature APIs from adoption to migration
(cherry picked from commit 085078d)
1 parent 4e6071c commit 61c8e70

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
@@ -4810,7 +4810,7 @@ ActorIsolation ActorIsolationChecker::determineClosureIsolation(
48104810
isolation = isolation.withPreconcurrency(preconcurrency);
48114811

48124812
if (ctx.LangOpts.getFeatureState(Feature::NonisolatedNonsendingByDefault)
4813-
.isEnabledForAdoption()) {
4813+
.isEnabledForMigration()) {
48144814
warnAboutNewNonisolatedAsyncExecutionBehavior(ctx, closure, isolation);
48154815
}
48164816

@@ -6296,7 +6296,7 @@ InferredActorIsolation ActorIsolationRequest::evaluate(Evaluator &evaluator,
62966296

62976297
auto &ctx = value->getASTContext();
62986298
if (ctx.LangOpts.getFeatureState(Feature::NonisolatedNonsendingByDefault)
6299-
.isEnabledForAdoption()) {
6299+
.isEnabledForMigration()) {
63006300
warnAboutNewNonisolatedAsyncExecutionBehavior(ctx, value,
63016301
inferredIsolation.isolation);
63026302
}

lib/Sema/TypeCheckType.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4252,7 +4252,7 @@ NeverNullType TypeResolver::resolveASTFunctionType(
42524252
isolation = FunctionTypeIsolation::forNonIsolated();
42534253
} else {
42544254
if (ctx.LangOpts.getFeatureState(Feature::NonisolatedNonsendingByDefault)
4255-
.isEnabledForAdoption()) {
4255+
.isEnabledForMigration()) {
42564256
// Diagnose only in the interface stage, which is run once.
42574257
if (inStage(TypeResolutionStage::Interface)) {
42584258
warnAboutNewNonisolatedAsyncExecutionBehavior(ctx, repr, isolation);
@@ -6578,7 +6578,7 @@ class ExistentialTypeSyntaxChecker : public ASTWalker {
65786578
// A missing `any` or `some` is always diagnosed if this feature not
65796579
// disabled.
65806580
auto featureState = ctx.LangOpts.getFeatureState(Feature::ExistentialAny);
6581-
if (featureState.isEnabled() || featureState.isEnabledForAdoption()) {
6581+
if (featureState.isEnabled() || featureState.isEnabledForMigration()) {
65826582
return true;
65836583
}
65846584

@@ -6671,10 +6671,10 @@ class ExistentialTypeSyntaxChecker : public ASTWalker {
66716671
/*isAlias=*/isa<TypeAliasDecl>(decl)));
66726672
}
66736673

6674-
// If `ExistentialAny` is enabled in adoption mode, warn unconditionally.
6674+
// If `ExistentialAny` is enabled in migration mode, warn unconditionally.
66756675
// Otherwise, warn until the feature's coming-of-age language mode.
66766676
const auto feature = Feature::ExistentialAny;
6677-
if (Ctx.LangOpts.getFeatureState(feature).isEnabledForAdoption()) {
6677+
if (Ctx.LangOpts.getFeatureState(feature).isEnabledForMigration()) {
66786678
diag->limitBehavior(DiagnosticBehavior::Warning);
66796679
} else {
66806680
diag->warnUntilSwiftVersion(feature.getLanguageVersion().value());

unittests/Frontend/FeatureParsingTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ void swift::PrintTo(const LangOptions::FeatureState::Kind &value,
5151
case LangOptions::FeatureState::Kind::Off:
5252
*os << "Off";
5353
break;
54-
case LangOptions::FeatureState::Kind::EnabledForAdoption:
55-
*os << "EnabledForAdoption";
54+
case LangOptions::FeatureState::Kind::EnabledForMigration:
55+
*os << "EnabledForMigration";
5656
break;
5757
case LangOptions::FeatureState::Kind::Enabled:
5858
*os << "Enabled";

unittests/Frontend/IsFeatureEnabledTests.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,27 @@ TEST_F(IsFeatureEnabledTest, VerifyTestedFeatures) {
3838
{
3939
ASSERT_FALSE(Feature::getUpcomingFeature(feature.name));
4040
ASSERT_FALSE(Feature::getExperimentalFeature(feature.name));
41-
ASSERT_FALSE(feature.id.isAdoptable());
41+
ASSERT_FALSE(feature.id.isMigratable());
4242
}
4343

4444
feature = upcomingF;
4545
{
4646
ASSERT_TRUE(Feature::getUpcomingFeature(feature.name));
47-
ASSERT_FALSE(feature.id.isAdoptable());
47+
ASSERT_FALSE(feature.id.isMigratable());
4848
ASSERT_LT(defaultLangMode, feature.langMode);
4949
}
5050

5151
feature = adoptableUpcomingF;
5252
{
5353
ASSERT_TRUE(Feature::getUpcomingFeature(feature.name));
54-
ASSERT_TRUE(feature.id.isAdoptable());
54+
ASSERT_TRUE(feature.id.isMigratable());
5555
ASSERT_LT(defaultLangMode, feature.langMode);
5656
}
5757

5858
feature = strictConcurrencyF;
5959
{
6060
ASSERT_TRUE(Feature::getUpcomingFeature(feature.name));
61-
ASSERT_FALSE(feature.id.isAdoptable());
61+
ASSERT_FALSE(feature.id.isMigratable());
6262
ASSERT_LT(defaultLangMode, feature.langMode);
6363
}
6464

@@ -68,7 +68,7 @@ TEST_F(IsFeatureEnabledTest, VerifyTestedFeatures) {
6868
// it for another experimental feature one that is available in production.
6969
ASSERT_TRUE(feature.id.isAvailableInProduction());
7070
ASSERT_TRUE(Feature::getExperimentalFeature(feature.name));
71-
ASSERT_FALSE(feature.id.isAdoptable());
71+
ASSERT_FALSE(feature.id.isMigratable());
7272
}
7373
}
7474

@@ -158,7 +158,7 @@ static const IsFeatureEnabledTestCase singleEnableTestCases[] = {
158158
{{adoptableUpcomingF, FeatureState::Off}}),
159159
IsFeatureEnabledTestCase(
160160
{"-enable-upcoming-feature", adoptableUpcomingF.name + ":adoption"},
161-
{{adoptableUpcomingF, FeatureState::EnabledForAdoption}}),
161+
{{adoptableUpcomingF, FeatureState::EnabledForMigration}}),
162162
// Swift 7 is asserts-only.
163163
#ifndef NDEBUG
164164
// Requesting adoption mode in target language mode has no effect.
@@ -176,7 +176,7 @@ static const IsFeatureEnabledTestCase singleEnableTestCases[] = {
176176
{{adoptableUpcomingF, FeatureState::Off}}),
177177
IsFeatureEnabledTestCase(
178178
{"-enable-experimental-feature", adoptableUpcomingF.name + ":adoption"},
179-
{{adoptableUpcomingF, FeatureState::EnabledForAdoption}}),
179+
{{adoptableUpcomingF, FeatureState::EnabledForMigration}}),
180180
// Swift 7 is asserts-only.
181181
#ifndef NDEBUG
182182
// Requesting adoption mode in target language mode has no effect.
@@ -396,7 +396,7 @@ static const IsFeatureEnabledTestCase doubleEnableTestCases[] = {
396396
"-enable-upcoming-feature", adoptableUpcomingF.name,
397397
"-enable-upcoming-feature", adoptableUpcomingF.name + ":adoption",
398398
},
399-
{{adoptableUpcomingF, FeatureState::EnabledForAdoption}}),
399+
{{adoptableUpcomingF, FeatureState::EnabledForMigration}}),
400400
IsFeatureEnabledTestCase({
401401
"-enable-upcoming-feature", adoptableUpcomingF.name + ":undef",
402402
"-enable-experimental-feature", adoptableUpcomingF.name,
@@ -416,7 +416,7 @@ static const IsFeatureEnabledTestCase doubleEnableTestCases[] = {
416416
"-enable-upcoming-feature", adoptableUpcomingF.name,
417417
"-enable-experimental-feature", adoptableUpcomingF.name + ":adoption",
418418
},
419-
{{adoptableUpcomingF, FeatureState::EnabledForAdoption}}),
419+
{{adoptableUpcomingF, FeatureState::EnabledForMigration}}),
420420
IsFeatureEnabledTestCase({
421421
"-enable-experimental-feature", adoptableUpcomingF.name + ":undef",
422422
"-enable-upcoming-feature", adoptableUpcomingF.name,
@@ -436,7 +436,7 @@ static const IsFeatureEnabledTestCase doubleEnableTestCases[] = {
436436
"-enable-experimental-feature", adoptableUpcomingF.name,
437437
"-enable-upcoming-feature", adoptableUpcomingF.name + ":adoption",
438438
},
439-
{{adoptableUpcomingF, FeatureState::EnabledForAdoption}}),
439+
{{adoptableUpcomingF, FeatureState::EnabledForMigration}}),
440440
IsFeatureEnabledTestCase({
441441
"-enable-experimental-feature", adoptableUpcomingF.name + ":undef",
442442
"-enable-experimental-feature", adoptableUpcomingF.name,
@@ -456,7 +456,7 @@ static const IsFeatureEnabledTestCase doubleEnableTestCases[] = {
456456
"-enable-experimental-feature", adoptableUpcomingF.name,
457457
"-enable-experimental-feature", adoptableUpcomingF.name + ":adoption",
458458
},
459-
{{adoptableUpcomingF, FeatureState::EnabledForAdoption}}),
459+
{{adoptableUpcomingF, FeatureState::EnabledForMigration}}),
460460

461461
// MARK: Experimental
462462

0 commit comments

Comments
 (0)