Skip to content

Commit 2956a76

Browse files
committed
Basic: Define ExistentialAny as supporting adoption mode
1 parent fbc69a4 commit 2956a76

File tree

4 files changed

+177
-1
lines changed

4 files changed

+177
-1
lines changed

include/swift/Basic/Features.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ UPCOMING_FEATURE(NonfrozenEnumExhaustivity, 192, 6)
269269
UPCOMING_FEATURE(GlobalActorIsolatedTypesUsability, 0434, 6)
270270

271271
// Swift 7
272-
UPCOMING_FEATURE(ExistentialAny, 335, 7)
272+
ADOPTABLE_UPCOMING_FEATURE(ExistentialAny, 335, 7)
273273
UPCOMING_FEATURE(InternalImportsByDefault, 409, 7)
274274
UPCOMING_FEATURE(MemberImportVisibility, 444, 7)
275275

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// NB: Repetitions are intentional. We are testing that a diagnostic is emitted
2+
// for each option, not just the last one found.
3+
4+
// RUN: %target-swift-frontend -parse -swift-version 6 \
5+
// RUN: -enable-upcoming-feature ExistentialAny:invalid1 \
6+
// RUN: -enable-upcoming-feature ExistentialAny:adoption \
7+
// RUN: -enable-experimental-feature ExistentialAny:invalid2 \
8+
// RUN: -enable-experimental-feature ExistentialAny:adoption \
9+
// RUN: -disable-upcoming-feature ExistentialAny:adoption \
10+
// RUN: -disable-experimental-feature ExistentialAny:adoption \
11+
// RUN: %s 2>&1 | %FileCheck %s --check-prefix=CHECK-SWIFT-5
12+
13+
// RUN: %target-swift-frontend -parse -swift-version 7 \
14+
// RUN: -enable-upcoming-feature ExistentialAny:invalid1 \
15+
// RUN: -enable-upcoming-feature ExistentialAny:adoption \
16+
// RUN: -enable-experimental-feature ExistentialAny:invalid2 \
17+
// RUN: -enable-experimental-feature ExistentialAny:adoption \
18+
// RUN: -disable-upcoming-feature ExistentialAny:adoption \
19+
// RUN: -disable-experimental-feature ExistentialAny:adoption \
20+
// RUN: %s 2>&1 | %FileCheck %s --check-prefix=CHECK-SWIFT-7
21+
22+
// REQUIRES: swift_feature_ExistentialAny
23+
// REQUIRES: asserts
24+
25+
// CHECK-NOT: error:
26+
27+
// CHECK-SWIFT-5-NOT: warning:
28+
// CHECK-SWIFT-5: warning: '-disable-experimental-feature' argument 'ExistentialAny:adoption' cannot specify a mode{{$}}
29+
// CHECK-SWIFT-5-NEXT: warning: '-disable-upcoming-feature' argument 'ExistentialAny:adoption' cannot specify a mode{{$}}
30+
// CHECK-SWIFT-5-NEXT: warning: 'invalid2' is not a recognized mode for feature 'ExistentialAny'; did you mean 'adoption'?{{$}}
31+
// CHECK-SWIFT-5-NEXT: warning: 'invalid1' is not a recognized mode for feature 'ExistentialAny'; did you mean 'adoption'?{{$}}
32+
// CHECK-SWIFT-5-NOT: warning:
33+
34+
// CHECK-SWIFT-7-NOT: warning:
35+
// CHECK-SWIFT-7-COUNT-6: warning: upcoming feature 'ExistentialAny' is already enabled as of Swift version 7{{$}}
36+
// CHECK-SWIFT-7-NOT: warning:
37+
38+
// CHECK-NOT: error:

test/Misc/verify-swift-feature-testing.test-sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ EXCEPTIONAL_FILES = [
1818
pathlib.Path("test/Frontend/upcoming_feature.swift"),
1919
pathlib.Path("test/Frontend/strict_features.swift"),
2020
pathlib.Path("test/Frontend/strict_features_adoption_mode.swift"),
21+
pathlib.Path("test/Frontend/strict_features_adoption_mode_adoptable_feature.swift"),
2122
# Tests for ModuleInterfaceExportAs being ignored
2223
pathlib.Path("test/ModuleInterface/swift-export-as.swift"),
2324
# Uses the pseudo-feature AvailabilityMacro=

unittests/Frontend/IsFeatureEnabledTests.cpp

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ namespace {
1919

2020
static const FeatureWrapper baselineF(Feature::AsyncAwait);
2121
static const FeatureWrapper upcomingF(Feature::DynamicActorIsolation);
22+
static const FeatureWrapper adoptableUpcomingF(Feature::ExistentialAny);
2223
static const FeatureWrapper experimentalF(Feature::NamedOpaqueTypes);
2324
static const FeatureWrapper strictConcurrencyF(Feature::StrictConcurrency);
2425

@@ -47,6 +48,13 @@ TEST_F(IsFeatureEnabledTest, VerifyTestedFeatures) {
4748
ASSERT_LT(defaultLangMode, feature.langMode);
4849
}
4950

51+
feature = adoptableUpcomingF;
52+
{
53+
ASSERT_TRUE(getUpcomingFeature(feature.name));
54+
ASSERT_TRUE(isFeatureAdoptable(feature));
55+
ASSERT_LT(defaultLangMode, feature.langMode);
56+
}
57+
5058
feature = strictConcurrencyF;
5159
{
5260
ASSERT_TRUE(getUpcomingFeature(feature.name));
@@ -82,6 +90,7 @@ static const IsFeatureEnabledTestCase defaultStateTestCases[] = {
8290
{}, {
8391
{baselineF, FeatureState::Enabled},
8492
{upcomingF, FeatureState::Off},
93+
{adoptableUpcomingF, FeatureState::Off},
8594
{strictConcurrencyF, FeatureState::Off},
8695
{experimentalF, FeatureState::Off},
8796
}),
@@ -118,6 +127,7 @@ static const IsFeatureEnabledTestCase singleEnableTestCases[] = {
118127
IsFeatureEnabledTestCase(
119128
{"-enable-experimental-feature", baselineF.name + ":adoption"},
120129
{{baselineF, FeatureState::Enabled}}),
130+
121131
IsFeatureEnabledTestCase(
122132
{"-enable-upcoming-feature", upcomingF.name},
123133
{{upcomingF, FeatureState::Enabled}}),
@@ -136,6 +146,43 @@ static const IsFeatureEnabledTestCase singleEnableTestCases[] = {
136146
IsFeatureEnabledTestCase(
137147
{"-enable-experimental-feature", upcomingF.name + ":adoption"},
138148
{{upcomingF, FeatureState::Off}}),
149+
150+
IsFeatureEnabledTestCase(
151+
{"-enable-upcoming-feature", adoptableUpcomingF.name},
152+
{{adoptableUpcomingF, FeatureState::Enabled}}),
153+
IsFeatureEnabledTestCase(
154+
{"-enable-upcoming-feature", adoptableUpcomingF.name + ":undef"},
155+
{{adoptableUpcomingF, FeatureState::Off}}),
156+
IsFeatureEnabledTestCase(
157+
{"-enable-upcoming-feature", adoptableUpcomingF.name + ":adoption"},
158+
{{adoptableUpcomingF, FeatureState::EnabledForAdoption}}),
159+
// Swift 7 is asserts-only.
160+
#ifndef NDEBUG
161+
// Requesting adoption mode in target language mode has no effect.
162+
IsFeatureEnabledTestCase({
163+
"-swift-version", adoptableUpcomingF.langMode,
164+
"-enable-upcoming-feature", adoptableUpcomingF.name + ":adoption",
165+
},
166+
{{adoptableUpcomingF, FeatureState::Enabled}}),
167+
#endif
168+
IsFeatureEnabledTestCase(
169+
{"-enable-experimental-feature", adoptableUpcomingF.name},
170+
{{adoptableUpcomingF, FeatureState::Enabled}}),
171+
IsFeatureEnabledTestCase(
172+
{"-enable-experimental-feature", adoptableUpcomingF.name + ":undef"},
173+
{{adoptableUpcomingF, FeatureState::Off}}),
174+
IsFeatureEnabledTestCase(
175+
{"-enable-experimental-feature", adoptableUpcomingF.name + ":adoption"},
176+
{{adoptableUpcomingF, FeatureState::EnabledForAdoption}}),
177+
// Swift 7 is asserts-only.
178+
#ifndef NDEBUG
179+
// Requesting adoption mode in target language mode has no effect.
180+
IsFeatureEnabledTestCase({
181+
"-swift-version", adoptableUpcomingF.langMode,
182+
"-enable-experimental-feature", adoptableUpcomingF.name + ":adoption",
183+
},
184+
{{adoptableUpcomingF, FeatureState::Enabled}}),
185+
#endif
139186
IsFeatureEnabledTestCase(
140187
{"-enable-upcoming-feature", strictConcurrencyF.name},
141188
{{strictConcurrencyF, FeatureState::Enabled}}),
@@ -154,6 +201,7 @@ static const IsFeatureEnabledTestCase singleEnableTestCases[] = {
154201
IsFeatureEnabledTestCase(
155202
{"-enable-experimental-feature", strictConcurrencyF.name + ":adoption"},
156203
{{strictConcurrencyF, FeatureState::Off}}),
204+
157205
IsFeatureEnabledTestCase(
158206
{"-enable-upcoming-feature", experimentalF.name},
159207
{{experimentalF, FeatureState::Off}}),
@@ -240,6 +288,9 @@ INSTANTIATE_TEST_SUITE_P(SingleDisable, IsFeatureEnabledTest,
240288

241289
// clang-format off
242290
static const IsFeatureEnabledTestCase doubleEnableTestCases[] = {
291+
292+
// MARK: Non-adoptable & upcoming
293+
243294
IsFeatureEnabledTestCase({
244295
"-enable-upcoming-feature", upcomingF.name + ":undef",
245296
"-enable-upcoming-feature", upcomingF.name,
@@ -320,6 +371,92 @@ static const IsFeatureEnabledTestCase doubleEnableTestCases[] = {
320371
"-enable-experimental-feature", upcomingF.name + ":adoption",
321372
},
322373
{{upcomingF, FeatureState::Enabled}}),
374+
375+
// MARK: Adoptable & upcoming
376+
377+
IsFeatureEnabledTestCase({
378+
"-enable-upcoming-feature", adoptableUpcomingF.name + ":undef",
379+
"-enable-upcoming-feature", adoptableUpcomingF.name,
380+
},
381+
{{adoptableUpcomingF, FeatureState::Enabled}}),
382+
IsFeatureEnabledTestCase({
383+
"-enable-upcoming-feature", adoptableUpcomingF.name + ":adoption",
384+
"-enable-upcoming-feature", adoptableUpcomingF.name,
385+
},
386+
{{adoptableUpcomingF, FeatureState::Enabled}}),
387+
IsFeatureEnabledTestCase({
388+
"-enable-upcoming-feature", adoptableUpcomingF.name,
389+
"-enable-upcoming-feature", adoptableUpcomingF.name + ":undef",
390+
},
391+
{{adoptableUpcomingF, FeatureState::Enabled}}),
392+
IsFeatureEnabledTestCase({
393+
"-enable-upcoming-feature", adoptableUpcomingF.name,
394+
"-enable-upcoming-feature", adoptableUpcomingF.name + ":adoption",
395+
},
396+
{{adoptableUpcomingF, FeatureState::EnabledForAdoption}}),
397+
IsFeatureEnabledTestCase({
398+
"-enable-upcoming-feature", adoptableUpcomingF.name + ":undef",
399+
"-enable-experimental-feature", adoptableUpcomingF.name,
400+
},
401+
{{adoptableUpcomingF, FeatureState::Enabled}}),
402+
IsFeatureEnabledTestCase({
403+
"-enable-upcoming-feature", adoptableUpcomingF.name + ":adoption",
404+
"-enable-experimental-feature", adoptableUpcomingF.name,
405+
},
406+
{{adoptableUpcomingF, FeatureState::Enabled}}),
407+
IsFeatureEnabledTestCase({
408+
"-enable-upcoming-feature", adoptableUpcomingF.name,
409+
"-enable-experimental-feature", adoptableUpcomingF.name + ":undef",
410+
},
411+
{{adoptableUpcomingF, FeatureState::Enabled}}),
412+
IsFeatureEnabledTestCase({
413+
"-enable-upcoming-feature", adoptableUpcomingF.name,
414+
"-enable-experimental-feature", adoptableUpcomingF.name + ":adoption",
415+
},
416+
{{adoptableUpcomingF, FeatureState::EnabledForAdoption}}),
417+
IsFeatureEnabledTestCase({
418+
"-enable-experimental-feature", adoptableUpcomingF.name + ":undef",
419+
"-enable-upcoming-feature", adoptableUpcomingF.name,
420+
},
421+
{{adoptableUpcomingF, FeatureState::Enabled}}),
422+
IsFeatureEnabledTestCase({
423+
"-enable-experimental-feature", adoptableUpcomingF.name + ":adoption",
424+
"-enable-upcoming-feature", adoptableUpcomingF.name,
425+
},
426+
{{adoptableUpcomingF, FeatureState::Enabled}}),
427+
IsFeatureEnabledTestCase({
428+
"-enable-experimental-feature", adoptableUpcomingF.name,
429+
"-enable-upcoming-feature", adoptableUpcomingF.name + ":undef",
430+
},
431+
{{adoptableUpcomingF, FeatureState::Enabled}}),
432+
IsFeatureEnabledTestCase({
433+
"-enable-experimental-feature", adoptableUpcomingF.name,
434+
"-enable-upcoming-feature", adoptableUpcomingF.name + ":adoption",
435+
},
436+
{{adoptableUpcomingF, FeatureState::EnabledForAdoption}}),
437+
IsFeatureEnabledTestCase({
438+
"-enable-experimental-feature", adoptableUpcomingF.name + ":undef",
439+
"-enable-experimental-feature", adoptableUpcomingF.name,
440+
},
441+
{{adoptableUpcomingF, FeatureState::Enabled}}),
442+
IsFeatureEnabledTestCase({
443+
"-enable-experimental-feature", adoptableUpcomingF.name + ":adoption",
444+
"-enable-experimental-feature", adoptableUpcomingF.name,
445+
},
446+
{{adoptableUpcomingF, FeatureState::Enabled}}),
447+
IsFeatureEnabledTestCase({
448+
"-enable-experimental-feature", adoptableUpcomingF.name,
449+
"-enable-experimental-feature", adoptableUpcomingF.name + ":undef",
450+
},
451+
{{adoptableUpcomingF, FeatureState::Enabled}}),
452+
IsFeatureEnabledTestCase({
453+
"-enable-experimental-feature", adoptableUpcomingF.name,
454+
"-enable-experimental-feature", adoptableUpcomingF.name + ":adoption",
455+
},
456+
{{adoptableUpcomingF, FeatureState::EnabledForAdoption}}),
457+
458+
// MARK: Experimental
459+
323460
IsFeatureEnabledTestCase({
324461
"-enable-experimental-feature", experimentalF.name + ":undef",
325462
"-enable-experimental-feature", experimentalF.name,

0 commit comments

Comments
 (0)