Skip to content

Commit fe1ae75

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.
1 parent 65d9f5f commit fe1ae75

16 files changed

+99
-99
lines changed

include/swift/AST/DeclAttr.def

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

880-
SIMPLE_DECL_ATTR(extensible, Extensible,
880+
SIMPLE_DECL_ATTR(nonexhaustive, Nonexhaustive,
881881
OnEnum,
882882
ABIStableToAdd | ABIStableToRemove | APIBreakingToAdd | APIStableToRemove | ForbiddenInABIAttr,
883883
169)
884-
DECL_ATTR_FEATURE_REQUIREMENT(Extensible, ExtensibleAttribute)
884+
DECL_ATTR_FEATURE_REQUIREMENT(Nonexhaustive, NonexhaustiveAttribute)
885885

886886
SIMPLE_DECL_ATTR(concurrent, Concurrent,
887887
OnFunc | OnConstructor | OnSubscript | OnVar,
@@ -892,7 +892,7 @@ SIMPLE_DECL_ATTR(preEnumExtensibility, PreEnumExtensibility,
892892
OnEnum,
893893
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIBreakingToRemove | UnconstrainedInABIAttr,
894894
171)
895-
DECL_ATTR_FEATURE_REQUIREMENT(PreEnumExtensibility, ExtensibleAttribute)
895+
DECL_ATTR_FEATURE_REQUIREMENT(PreEnumExtensibility, NonexhaustiveAttribute)
896896

897897
DECL_ATTR(specialized, Specialized,
898898
OnConstructor | OnFunc | OnAccessor,

include/swift/AST/DiagnosticsSema.def

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8799,20 +8799,20 @@ GROUPED_WARNING(
87998799
(StringRef))
88008800

88018801
//===----------------------------------------------------------------------===//
8802-
// MARK: @extensible and @preEnumExtensibility Attributes
8802+
// MARK: @nonexhaustive and @preEnumExtensibility Attributes
88038803
//===----------------------------------------------------------------------===//
88048804

8805-
ERROR(extensible_attr_on_frozen_type,none,
8806-
"cannot use '@extensible' together with '@frozen'", ())
8805+
ERROR(nonexhaustive_attr_on_frozen_type,none,
8806+
"cannot use '@nonexhaustive' together with '@frozen'", ())
88078807

8808-
ERROR(extensible_attr_on_internal_type,none,
8809-
"'@extensible' attribute can only be applied to public or package "
8808+
ERROR(nonexhaustive_attr_on_internal_type,none,
8809+
"'@nonexhaustive' attribute can only be applied to public or package "
88108810
"declarations, but %0 is "
88118811
"%select{private|fileprivate|internal|%error|%error|%error}1",
88128812
(DeclName, AccessLevel))
88138813

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

88178817
//===----------------------------------------------------------------------===//
88188818
// MARK: `using` declaration

include/swift/Basic/Features.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,8 @@ EXPERIMENTAL_FEATURE(AllowRuntimeSymbolDeclarations, true)
519519
/// Allow use of `@cdecl`
520520
EXPERIMENTAL_FEATURE(CDecl, false)
521521

522-
/// Allow use of `@extensible` on public enums
523-
SUPPRESSIBLE_EXPERIMENTAL_FEATURE(ExtensibleAttribute, false)
522+
/// Allow use of `@nonexhaustive` on public enums
523+
SUPPRESSIBLE_EXPERIMENTAL_FEATURE(NonexhaustiveAttribute, false)
524524

525525
/// Allow use of `Module::name` syntax
526526
EXPERIMENTAL_FEATURE(ModuleSelector, false)

lib/AST/ASTDumper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5047,7 +5047,7 @@ class PrintAttribute : public AttributeVisitor<PrintAttribute, void, Label>,
50475047
TRIVIAL_ATTR_PRINTER(Used, used)
50485048
TRIVIAL_ATTR_PRINTER(WarnUnqualifiedAccess, warn_unqualified_access)
50495049
TRIVIAL_ATTR_PRINTER(WeakLinked, weak_linked)
5050-
TRIVIAL_ATTR_PRINTER(Extensible, extensible)
5050+
TRIVIAL_ATTR_PRINTER(Nonexhaustive, nonexhaustive)
50515051
TRIVIAL_ATTR_PRINTER(Concurrent, concurrent)
50525052
TRIVIAL_ATTR_PRINTER(PreEnumExtensibility, preEnumExtensibility)
50535053

lib/AST/ASTPrinter.cpp

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

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

lib/AST/Decl.cpp

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

7038-
// When the enum is marked as `@extensible` cross-module access
7038+
// When the enum is marked as `@nonexhaustive` cross-module access
70397039
// cannot be exhaustive and requires `@unknown default:`.
7040-
if (getAttrs().hasAttribute<ExtensibleAttr>() &&
7040+
if (getAttrs().hasAttribute<NonexhaustiveAttr>() &&
70417041
enumModule != useDC->getParentModule())
70427042
return false;
70437043
}

lib/AST/FeatureSet.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -667,8 +667,8 @@ static bool usesFeatureAsyncExecutionBehaviorAttributes(Decl *decl) {
667667
return false;
668668
}
669669

670-
static bool usesFeatureExtensibleAttribute(Decl *decl) {
671-
return decl->getAttrs().hasAttribute<ExtensibleAttr>();
670+
static bool usesFeatureNonexhaustiveAttribute(Decl *decl) {
671+
return decl->getAttrs().hasAttribute<NonexhaustiveAttr>();
672672
}
673673

674674
static bool usesFeatureAlwaysInheritActorContext(Decl *decl) {

lib/ASTGen/Sources/ASTGen/DeclAttrs.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ extension ASTGenVisitor {
239239
.DynamicCallable,
240240
.EagerMove,
241241
.Exported,
242-
.Extensible,
242+
.Nonexhaustive,
243243
.PreEnumExtensibility,
244244
.DiscardableResult,
245245
.DisfavoredOverload,

lib/Sema/TypeCheckAttr.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,25 +233,25 @@ class AttributeChecker : public AttributeVisitor<AttributeChecker> {
233233
}
234234
}
235235

236-
void visitExtensibleAttr(ExtensibleAttr *attr) {
236+
void visitNonexhaustiveAttr(NonexhaustiveAttr *attr) {
237237
auto *E = cast<EnumDecl>(D);
238238

239239
if (D->getAttrs().hasAttribute<FrozenAttr>()) {
240-
diagnoseAndRemoveAttr(attr, diag::extensible_attr_on_frozen_type);
240+
diagnoseAndRemoveAttr(attr, diag::nonexhaustive_attr_on_frozen_type);
241241
return;
242242
}
243243

244244
if (E->getFormalAccess() < AccessLevel::Package) {
245-
diagnoseAndRemoveAttr(attr, diag::extensible_attr_on_internal_type,
245+
diagnoseAndRemoveAttr(attr, diag::nonexhaustive_attr_on_internal_type,
246246
E->getName(), E->getFormalAccess());
247247
return;
248248
}
249249
}
250250

251251
void visitPreEnumExtensibilityAttr(PreEnumExtensibilityAttr *attr) {
252-
if (!D->getAttrs().hasAttribute<ExtensibleAttr>()) {
252+
if (!D->getAttrs().hasAttribute<NonexhaustiveAttr>()) {
253253
diagnoseAndRemoveAttr(
254-
attr, diag::pre_enum_extensibility_without_extensible, attr);
254+
attr, diag::pre_enum_extensibility_without_nonexhaustive, attr);
255255
return;
256256
}
257257
}

lib/Sema/TypeCheckDeclOverride.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1614,7 +1614,7 @@ namespace {
16141614
UNINTERESTING_ATTR(Isolated)
16151615
UNINTERESTING_ATTR(Optimize)
16161616
UNINTERESTING_ATTR(Exclusivity)
1617-
UNINTERESTING_ATTR(Extensible)
1617+
UNINTERESTING_ATTR(Nonexhaustive)
16181618
UNINTERESTING_ATTR(PreEnumExtensibility)
16191619
UNINTERESTING_ATTR(NoLocks)
16201620
UNINTERESTING_ATTR(NoAllocation)

0 commit comments

Comments
 (0)