Skip to content

Commit c972233

Browse files
committed
[AST/Sema] SE-0487: Rename @extensible into @nonexhaustive
This is an accepted spelling for the attribute. This commit also renames the feature flag from `ExtensibleAttribute` to `NonexhaustiveAttribute` to match the spelling of the attribute. (cherry picked from commit fe1ae75)
1 parent cefa0b2 commit c972233

16 files changed

+101
-101
lines changed

include/swift/AST/DeclAttr.def

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -876,11 +876,11 @@ SIMPLE_DECL_ATTR(constInitialized, ConstInitialized,
876876
168)
877877
DECL_ATTR_FEATURE_REQUIREMENT(ConstInitialized, CompileTimeValues)
878878

879-
SIMPLE_DECL_ATTR(extensible, Extensible,
879+
SIMPLE_DECL_ATTR(nonexhaustive, Nonexhaustive,
880880
OnEnum,
881881
ABIStableToAdd | ABIStableToRemove | APIBreakingToAdd | APIStableToRemove | ForbiddenInABIAttr,
882882
169)
883-
DECL_ATTR_FEATURE_REQUIREMENT(Extensible, ExtensibleAttribute)
883+
DECL_ATTR_FEATURE_REQUIREMENT(Nonexhaustive, NonexhaustiveAttribute)
884884

885885
SIMPLE_DECL_ATTR(concurrent, Concurrent,
886886
OnFunc | OnConstructor | OnSubscript | OnVar,
@@ -891,8 +891,8 @@ SIMPLE_DECL_ATTR(preEnumExtensibility, PreEnumExtensibility,
891891
OnEnum,
892892
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIBreakingToRemove | UnconstrainedInABIAttr,
893893
171)
894-
DECL_ATTR_FEATURE_REQUIREMENT(PreEnumExtensibility, ExtensibleAttribute)
895-
894+
DECL_ATTR_FEATURE_REQUIREMENT(PreEnumExtensibility, NonexhaustiveAttribute)
895+
896896
LAST_DECL_ATTR(PreEnumExtensibility)
897897

898898
#undef DECL_ATTR_ALIAS

include/swift/AST/DiagnosticsSema.def

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8712,20 +8712,20 @@ GROUPED_WARNING(
87128712
(StringRef))
87138713

87148714
//===----------------------------------------------------------------------===//
8715-
// MARK: @extensible and @preEnumExtensibility Attributes
8715+
// MARK: @nonexhaustive and @preEnumExtensibility Attributes
87168716
//===----------------------------------------------------------------------===//
87178717

8718-
ERROR(extensible_attr_on_frozen_type,none,
8719-
"cannot use '@extensible' together with '@frozen'", ())
8718+
ERROR(nonexhaustive_attr_on_frozen_type,none,
8719+
"cannot use '@nonexhaustive' together with '@frozen'", ())
87208720

8721-
ERROR(extensible_attr_on_internal_type,none,
8722-
"'@extensible' attribute can only be applied to public or package "
8721+
ERROR(nonexhaustive_attr_on_internal_type,none,
8722+
"'@nonexhaustive' attribute can only be applied to public or package "
87238723
"declarations, but %0 is "
87248724
"%select{private|fileprivate|internal|%error|%error|%error}1",
87258725
(DeclName, AccessLevel))
87268726

8727-
ERROR(pre_enum_extensibility_without_extensible,none,
8728-
"%0 can only be used together with '@extensible' attribute", (DeclAttribute))
8727+
ERROR(pre_enum_extensibility_without_nonexhaustive,none,
8728+
"%0 can only be used together with '@nonexhaustive' attribute", (DeclAttribute))
87298729

87308730
//===----------------------------------------------------------------------===//
87318731
// MARK: `using` declaration

include/swift/Basic/Features.def

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,16 +520,16 @@ EXPERIMENTAL_FEATURE(AllowRuntimeSymbolDeclarations, true)
520520
/// Optimize copies of ObjectiveC blocks.
521521
EXPERIMENTAL_FEATURE(CopyBlockOptimization, true)
522522

523+
/// Allow use of `@nonexhaustive` on public enums
524+
SUPPRESSIBLE_EXPERIMENTAL_FEATURE(NonexhaustiveAttribute, false)
525+
523526
/// Allow use of `using` declaration that control default isolation
524527
/// in a file scope.
525528
EXPERIMENTAL_FEATURE(DefaultIsolationPerFile, false)
526529

527530
/// Enable @_lifetime attribute
528531
SUPPRESSIBLE_EXPERIMENTAL_FEATURE(Lifetimes, true)
529532

530-
/// Allow use of `@extensible` on public enums
531-
SUPPRESSIBLE_EXPERIMENTAL_FEATURE(ExtensibleAttribute, false)
532-
533533
#undef EXPERIMENTAL_FEATURE_EXCLUDED_FROM_MODULE_INTERFACE
534534
#undef EXPERIMENTAL_FEATURE
535535
#undef UPCOMING_FEATURE

lib/AST/ASTDumper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5064,7 +5064,7 @@ class PrintAttribute : public AttributeVisitor<PrintAttribute, void, Label>,
50645064
TRIVIAL_ATTR_PRINTER(Used, used)
50655065
TRIVIAL_ATTR_PRINTER(WarnUnqualifiedAccess, warn_unqualified_access)
50665066
TRIVIAL_ATTR_PRINTER(WeakLinked, weak_linked)
5067-
TRIVIAL_ATTR_PRINTER(Extensible, extensible)
5067+
TRIVIAL_ATTR_PRINTER(Nonexhaustive, nonexhaustive)
50685068
TRIVIAL_ATTR_PRINTER(Concurrent, concurrent)
50695069
TRIVIAL_ATTR_PRINTER(PreEnumExtensibility, preEnumExtensibility)
50705070

lib/AST/ASTPrinter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3326,9 +3326,9 @@ suppressingFeatureAddressableTypes(PrintOptions &options,
33263326
}
33273327

33283328
static void
3329-
suppressingFeatureExtensibleAttribute(PrintOptions &options,
3330-
llvm::function_ref<void()> action) {
3331-
ExcludeAttrRAII scope1(options.ExcludeAttrList, DeclAttrKind::Extensible);
3329+
suppressingFeatureNonexhaustiveAttribute(PrintOptions &options,
3330+
llvm::function_ref<void()> action) {
3331+
ExcludeAttrRAII scope1(options.ExcludeAttrList, DeclAttrKind::Nonexhaustive);
33323332
ExcludeAttrRAII scope2(options.ExcludeAttrList, DeclAttrKind::PreEnumExtensibility);
33333333
action();
33343334
}

lib/AST/Decl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7027,9 +7027,9 @@ bool EnumDecl::treatAsExhaustiveForDiags(const DeclContext *useDC) const {
70277027
if (enumModule->inSamePackage(useDC->getParentModule()))
70287028
return true;
70297029

7030-
// When the enum is marked as `@extensible` cross-module access
7030+
// When the enum is marked as `@nonexhaustive` cross-module access
70317031
// cannot be exhaustive and requires `@unknown default:`.
7032-
if (getAttrs().hasAttribute<ExtensibleAttr>() &&
7032+
if (getAttrs().hasAttribute<NonexhaustiveAttr>() &&
70337033
enumModule != useDC->getParentModule())
70347034
return false;
70357035
}

lib/AST/FeatureSet.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -656,8 +656,8 @@ static bool usesFeatureAsyncExecutionBehaviorAttributes(Decl *decl) {
656656
return false;
657657
}
658658

659-
static bool usesFeatureExtensibleAttribute(Decl *decl) {
660-
return decl->getAttrs().hasAttribute<ExtensibleAttr>();
659+
static bool usesFeatureNonexhaustiveAttribute(Decl *decl) {
660+
return decl->getAttrs().hasAttribute<NonexhaustiveAttr>();
661661
}
662662

663663
UNINTERESTING_FEATURE(BuiltinSelect)

lib/ASTGen/Sources/ASTGen/DeclAttrs.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ extension ASTGenVisitor {
228228
.dynamicCallable,
229229
.eagerMove,
230230
.exported,
231-
.extensible,
231+
.nonexhaustive,
232232
.preEnumExtensibility,
233233
.discardableResult,
234234
.disfavoredOverload,

lib/Sema/TypeCheckAttr.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,25 +247,25 @@ class AttributeChecker : public AttributeVisitor<AttributeChecker> {
247247
}
248248
}
249249

250-
void visitExtensibleAttr(ExtensibleAttr *attr) {
250+
void visitNonexhaustiveAttr(NonexhaustiveAttr *attr) {
251251
auto *E = cast<EnumDecl>(D);
252252

253253
if (D->getAttrs().hasAttribute<FrozenAttr>()) {
254-
diagnoseAndRemoveAttr(attr, diag::extensible_attr_on_frozen_type);
254+
diagnoseAndRemoveAttr(attr, diag::nonexhaustive_attr_on_frozen_type);
255255
return;
256256
}
257257

258258
if (E->getFormalAccess() < AccessLevel::Package) {
259-
diagnoseAndRemoveAttr(attr, diag::extensible_attr_on_internal_type,
259+
diagnoseAndRemoveAttr(attr, diag::nonexhaustive_attr_on_internal_type,
260260
E->getName(), E->getFormalAccess());
261261
return;
262262
}
263263
}
264264

265265
void visitPreEnumExtensibilityAttr(PreEnumExtensibilityAttr *attr) {
266-
if (!D->getAttrs().hasAttribute<ExtensibleAttr>()) {
266+
if (!D->getAttrs().hasAttribute<NonexhaustiveAttr>()) {
267267
diagnoseAndRemoveAttr(
268-
attr, diag::pre_enum_extensibility_without_extensible, attr);
268+
attr, diag::pre_enum_extensibility_without_nonexhaustive, attr);
269269
return;
270270
}
271271
}

lib/Sema/TypeCheckDeclOverride.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1616,7 +1616,7 @@ namespace {
16161616
UNINTERESTING_ATTR(Isolated)
16171617
UNINTERESTING_ATTR(Optimize)
16181618
UNINTERESTING_ATTR(Exclusivity)
1619-
UNINTERESTING_ATTR(Extensible)
1619+
UNINTERESTING_ATTR(Nonexhaustive)
16201620
UNINTERESTING_ATTR(PreEnumExtensibility)
16211621
UNINTERESTING_ATTR(NoLocks)
16221622
UNINTERESTING_ATTR(NoAllocation)

0 commit comments

Comments
 (0)