Skip to content

Commit afa6d64

Browse files
committed
[AST/Sema] SE-0487: Remove @preEnumExtensibility attribute
(cherry picked from commit 0444d29)
1 parent 277be31 commit afa6d64

File tree

8 files changed

+6
-146
lines changed

8 files changed

+6
-146
lines changed

include/swift/AST/DeclAttr.def

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -887,13 +887,9 @@ SIMPLE_DECL_ATTR(concurrent, Concurrent,
887887
ABIBreakingToAdd | ABIBreakingToRemove | APIBreakingToAdd | APIBreakingToRemove | UnconstrainedInABIAttr,
888888
170)
889889

890-
SIMPLE_DECL_ATTR(preEnumExtensibility, PreEnumExtensibility,
891-
OnEnum,
892-
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIBreakingToRemove | UnconstrainedInABIAttr,
893-
171)
894-
DECL_ATTR_FEATURE_REQUIREMENT(PreEnumExtensibility, NonexhaustiveAttribute)
890+
// Unused '171': Used to be `@preEnumExtensibility`
895891

896-
LAST_DECL_ATTR(PreEnumExtensibility)
892+
LAST_DECL_ATTR(Concurrent)
897893

898894
#undef DECL_ATTR_ALIAS
899895
#undef CONTEXTUAL_DECL_ATTR_ALIAS

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8724,9 +8724,6 @@ ERROR(nonexhaustive_attr_on_internal_type,none,
87248724
"%select{private|fileprivate|internal|%error|%error|%error}1",
87258725
(DeclName, AccessLevel))
87268726

8727-
ERROR(pre_enum_extensibility_without_nonexhaustive,none,
8728-
"%0 can only be used together with '@nonexhaustive' attribute", (DeclAttribute))
8729-
87308727
//===----------------------------------------------------------------------===//
87318728
// MARK: `using` declaration
87328729
//===----------------------------------------------------------------------===//

lib/AST/ASTDumper.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5066,7 +5066,6 @@ class PrintAttribute : public AttributeVisitor<PrintAttribute, void, Label>,
50665066
TRIVIAL_ATTR_PRINTER(WeakLinked, weak_linked)
50675067
TRIVIAL_ATTR_PRINTER(Nonexhaustive, nonexhaustive)
50685068
TRIVIAL_ATTR_PRINTER(Concurrent, concurrent)
5069-
TRIVIAL_ATTR_PRINTER(PreEnumExtensibility, preEnumExtensibility)
50705069

50715070
#undef TRIVIAL_ATTR_PRINTER
50725071

lib/AST/ASTPrinter.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3328,8 +3328,7 @@ suppressingFeatureAddressableTypes(PrintOptions &options,
33283328
static void
33293329
suppressingFeatureNonexhaustiveAttribute(PrintOptions &options,
33303330
llvm::function_ref<void()> action) {
3331-
ExcludeAttrRAII scope1(options.ExcludeAttrList, DeclAttrKind::Nonexhaustive);
3332-
ExcludeAttrRAII scope2(options.ExcludeAttrList, DeclAttrKind::PreEnumExtensibility);
3331+
ExcludeAttrRAII scope(options.ExcludeAttrList, DeclAttrKind::Nonexhaustive);
33333332
action();
33343333
}
33353334

lib/ASTGen/Sources/ASTGen/DeclAttrs.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ extension ASTGenVisitor {
229229
.eagerMove,
230230
.exported,
231231
.nonexhaustive,
232-
.preEnumExtensibility,
233232
.discardableResult,
234233
.disfavoredOverload,
235234
.dynamicMemberLookup,

lib/Sema/TypeCheckAttr.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -258,14 +258,6 @@ class AttributeChecker : public AttributeVisitor<AttributeChecker> {
258258
}
259259
}
260260

261-
void visitPreEnumExtensibilityAttr(PreEnumExtensibilityAttr *attr) {
262-
if (!D->getAttrs().hasAttribute<NonexhaustiveAttr>()) {
263-
diagnoseAndRemoveAttr(
264-
attr, diag::pre_enum_extensibility_without_nonexhaustive, attr);
265-
return;
266-
}
267-
}
268-
269261
void visitAlignmentAttr(AlignmentAttr *attr) {
270262
// Alignment must be a power of two.
271263
auto value = attr->getValue();

lib/Sema/TypeCheckDeclOverride.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1617,7 +1617,6 @@ namespace {
16171617
UNINTERESTING_ATTR(Optimize)
16181618
UNINTERESTING_ATTR(Exclusivity)
16191619
UNINTERESTING_ATTR(Nonexhaustive)
1620-
UNINTERESTING_ATTR(PreEnumExtensibility)
16211620
UNINTERESTING_ATTR(NoLocks)
16221621
UNINTERESTING_ATTR(NoAllocation)
16231622
UNINTERESTING_ATTR(NoRuntime)

test/IDE/complete_decl_attribute_feature_requirement.swift

Lines changed: 3 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -3,139 +3,18 @@
33
// it's enabled. When a feature becomes non-experimental, move its test cases
44
// into the normal complete_decl_attribute.swift test file.
55

6-
// NOTE: There are currently no experimental features that need code completion
7-
// testing, but this test file is being left in place for when it's needed
8-
// again. At that time, please remove the ABIAttribute tests.
9-
// REQUIRES: new_use_case
10-
116
// REQUIRES: asserts
127

138
// RUN: %batch-code-completion -filecheck-additional-suffix _DISABLED
149
// RUN: %batch-code-completion -filecheck-additional-suffix _ENABLED \
15-
// RUN: -enable-experimental-feature ABIAttribute \
16-
// RUN: -enable-experimental-feature ExtensibleAttribute
10+
// RUN: -enable-experimental-feature NonexhaustiveAttribute
1711

1812
// NOTE: Please do not include the ", N items" after "Begin completions". The
1913
// item count creates needless merge conflicts given that an "End completions"
2014
// line exists for each test.
2115

22-
@#^KEYWORD2^# func method(){}
23-
24-
// KEYWORD2: Begin completions
25-
// KEYWORD2_ENABLED-DAG: Keyword/None: abi[#Func Attribute#]; name=abi
26-
// KEYWORD2_DISABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi
27-
// KEYWORD2: End completions
28-
29-
@#^KEYWORD3^# class C {}
30-
31-
// KEYWORD3: Begin completions
32-
// KEYWORD3_ENABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi
33-
// KEYWORD3_DISABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi
34-
// KEYWORD3: End completions
35-
36-
@#^KEYWORD3_2?check=KEYWORD3^#IB class C2 {}
37-
// Same as KEYWORD3.
38-
3916
@#^KEYWORD4^# enum E {}
4017
// KEYWORD4: Begin completions
41-
// KEYWORD4_ENABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi
42-
// KEYWORD4_DISABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi
43-
// KEYWORD4_ENABLED-DAG: Keyword/None: extensible[#{{.*}} Attribute#]; name=extensible
44-
// KEYWORD4_DISABLED-NOT: Keyword/None: extensible[#{{.*}} Attribute#]; name=extensible
18+
// KEYWORD4_ENABLED-DAG: Keyword/None: nonexhaustive[#{{.*}} Attribute#]; name=nonexhaustive
19+
// KEYWORD4_DISABLED-NOT: Keyword/None: nonexhaustive[#{{.*}} Attribute#]; name=nonexhaustive
4520
// KEYWORD4: End completions
46-
47-
@#^KEYWORD5^# struct S{}
48-
// KEYWORD5: Begin completions
49-
// KEYWORD5_ENABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi
50-
// KEYWORD5_DISABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi
51-
// KEYWORD5: End completions
52-
53-
@#^ON_GLOBALVAR^# var globalVar
54-
// ON_GLOBALVAR: Begin completions
55-
// ON_GLOBALVAR_ENABLED-DAG: Keyword/None: abi[#Var Attribute#]; name=abi
56-
// ON_GLOBALVAR_DISABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi
57-
// ON_GLOBALVAR: End completions
58-
59-
struct _S {
60-
@#^ON_INIT^# init()
61-
// ON_INIT: Begin completions
62-
// ON_INIT_ENABLED-DAG: Keyword/None: abi[#Constructor Attribute#]; name=abi
63-
// ON_INIT_DISABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi
64-
// ON_INIT: End completions
65-
66-
@#^ON_PROPERTY^# var foo
67-
// ON_PROPERTY: Begin completions
68-
// ON_PROPERTY_ENABLED-DAG: Keyword/None: abi[#Var Attribute#]; name=abi
69-
// ON_PROPERTY_DISABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi
70-
// ON_PROPERTY: End completions
71-
72-
@#^ON_SUBSCR^# subscript
73-
// ON_SUBSCR: Begin completions
74-
// ON_SUBSCR_ENABLED-DAG: Keyword/None: abi[#Declaration Attribute#]; name=abi
75-
// ON_SUBSCR_DISABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi
76-
// ON_SUBSCR: End completions
77-
78-
@#^ON_METHOD^# private
79-
func foo()
80-
// ON_METHOD: Begin completions
81-
// ON_METHOD_ENABLED-DAG: Keyword/None: abi[#Func Attribute#]; name=abi
82-
// ON_METHOD_DISABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi
83-
// ON_METHOD: End completions
84-
85-
86-
func bar(@#^ON_PARAM_1?check=ON_PARAM^#)
87-
// ON_PARAM: Begin completions
88-
// ON_PARAM_ENABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi
89-
// ON_PARAM_DISABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi
90-
// ON_PARAM: End completions
91-
92-
func bar(
93-
@#^ON_PARAM_2?check=ON_PARAM^#
94-
95-
arg: Int
96-
)
97-
// Same as ON_PARAM.
98-
99-
@#^ON_MEMBER_INDEPENDENT_1?check=ON_MEMBER_LAST^#
100-
101-
func dummy1() {}
102-
// Same as ON_MEMBER_LAST.
103-
104-
@#^ON_MEMBER_INDEPENDENT_2?check=ON_MEMBER_LAST^#
105-
func dummy2() {}
106-
// Same as ON_MEMBER_LAST.
107-
108-
109-
@#^ON_MEMBER_LAST^#
110-
// ON_MEMBER_LAST: Begin completions
111-
// ON_MEMBER_LAST_ENABLED-DAG: Keyword/None: abi[#Declaration Attribute#]; name=abi
112-
// ON_MEMBER_LAST_DISABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi
113-
// ON_MEMBER_LAST: End completions
114-
}
115-
116-
func takeClosure(_: () -> Void) {
117-
takeClosure { @#^IN_CLOSURE^# in
118-
print("x")
119-
}
120-
}
121-
// IN_CLOSURE: Begin completions
122-
// FIXME: Not valid in this position (but CompletionLookup can't tell that)
123-
// IN_CLOSURE_ENABLED-DAG: Keyword/None: abi[#Declaration Attribute#]; name=abi
124-
// IN_CLOSURE_DISABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi
125-
// IN_CLOSURE: End completions
126-
127-
@#^KEYWORD_INDEPENDENT_1?check=KEYWORD_LAST^#
128-
129-
func dummy1() {}
130-
// Same as KEYWORD_LAST.
131-
132-
@#^KEYWORD_INDEPENDENT_2?check=KEYWORD_LAST^#
133-
func dummy2() {}
134-
// Same as KEYWORD_LAST.
135-
136-
@#^KEYWORD_LAST^#
137-
138-
// KEYWORD_LAST: Begin completions
139-
// KEYWORD_LAST_ENABLED-DAG: Keyword/None: abi[#Declaration Attribute#]; name=abi
140-
// KEYWORD_LAST_DISABLED-NOT: Keyword/None: abi[#Declaration Attribute#]; name=abi
141-
// KEYWORD_LAST: End completions

0 commit comments

Comments
 (0)