Skip to content

Commit 2e8d9a4

Browse files
committed
[SE-0258] Adopt @propertyWrapper everywhere.
1 parent 1e0e671 commit 2e8d9a4

17 files changed

+70
-66
lines changed

include/swift/AST/Attr.def

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,11 +401,9 @@ SIMPLE_DECL_ATTR(_implementationOnly, ImplementationOnly,
401401
DECL_ATTR(_custom, Custom,
402402
OnAnyDecl | UserInaccessible,
403403
85)
404-
SIMPLE_DECL_ATTR(_propertyWrapper, PropertyWrapper,
404+
SIMPLE_DECL_ATTR(propertyWrapper, PropertyWrapper,
405405
OnStruct | OnClass | OnEnum,
406406
86)
407-
DECL_ATTR_ALIAS(propertyDelegate, PropertyWrapper)
408-
DECL_ATTR_ALIAS(propertyWrapper, PropertyWrapper)
409407
SIMPLE_DECL_ATTR(_disfavoredOverload, DisfavoredOverload,
410408
OnAbstractFunction | OnVar | OnSubscript | UserInaccessible,
411409
87)

lib/Parse/ParseDecl.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,6 +1800,12 @@ ParserStatus Parser::parseDeclAttribute(DeclAttributes &Attributes, SourceLoc At
18001800
checkInvalidAttrName("_inlineable", "inlinable", DAK_Inlinable);
18011801
}
18021802

1803+
// Other names of property wrappers...
1804+
checkInvalidAttrName("propertyDelegate", "propertyWrapper",
1805+
DAK_PropertyWrapper, diag::attr_renamed_warning);
1806+
checkInvalidAttrName("_propertyWrapper", "propertyWrapper",
1807+
DAK_PropertyWrapper, diag::attr_renamed_warning);
1808+
18031809
if (DK == DAK_Count && Tok.getText() == "warn_unused_result") {
18041810
// The behavior created by @warn_unused_result is now the default. Emit a
18051811
// Fix-It to remove.

lib/Sema/TypeCheckPropertyWrapper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ static ConstructorDecl *findDefaultInit(ASTContext &ctx,
225225
llvm::Expected<PropertyWrapperTypeInfo>
226226
PropertyWrapperTypeInfoRequest::evaluate(
227227
Evaluator &eval, NominalTypeDecl *nominal) const {
228-
// We must have the @_propertyWrapper attribute to continue.
228+
// We must have the @propertyWrapper attribute to continue.
229229
if (!nominal->getAttrs().hasAttribute<PropertyWrapperAttr>()) {
230230
return PropertyWrapperTypeInfo();
231231
}
@@ -271,7 +271,7 @@ AttachedPropertyWrapperRequest::evaluate(Evaluator &evaluator,
271271
auto nominal = evaluateOrDefault(
272272
ctx.evaluator, CustomAttrNominalRequest{mutableAttr, dc}, nullptr);
273273

274-
// If we didn't find a nominal type with a @_propertyWrapper attribute,
274+
// If we didn't find a nominal type with a @propertyWrapper attribute,
275275
// skip this custom attribute.
276276
if (!nominal || !nominal->getAttrs().hasAttribute<PropertyWrapperAttr>())
277277
continue;

test/IDE/complete_decl_attribute.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class C {}
7575
// KEYWORD3-NEXT: Keyword/None: objcMembers[#Class Attribute#]; name=objcMembers{{$}}
7676
// KEYWORD3-NEXT: Keyword/None: NSApplicationMain[#Class Attribute#]; name=NSApplicationMain{{$}}
7777
// KEYWORD3-NEXT: Keyword/None: usableFromInline[#Class Attribute#]; name=usableFromInline
78-
// KEYWORD3-NEXT: Keyword/None: _propertyWrapper[#Class Attribute#]; name=_propertyWrapper
78+
// KEYWORD3-NEXT: Keyword/None: propertyWrapper[#Class Attribute#]; name=propertyWrapper
7979
// KEYWORD3-NEXT: Keyword/None: _functionBuilder[#Class Attribute#]; name=_functionBuilder
8080
// KEYWORD3-NEXT: End completions
8181

@@ -91,7 +91,7 @@ enum E {}
9191
// KEYWORD4-NEXT: Keyword/None: dynamicCallable[#Enum Attribute#]; name=dynamicCallable
9292
// KEYWORD4-NEXT: Keyword/None: dynamicMemberLookup[#Enum Attribute#]; name=dynamicMemberLookup
9393
// KEYWORD4-NEXT: Keyword/None: usableFromInline[#Enum Attribute#]; name=usableFromInline
94-
// KEYWORD4-NEXT: Keyword/None: _propertyWrapper[#Enum Attribute#]; name=_propertyWrapper
94+
// KEYWORD4-NEXT: Keyword/None: propertyWrapper[#Enum Attribute#]; name=propertyWrapper
9595
// KEYWORD4-NEXT: Keyword/None: _functionBuilder[#Enum Attribute#]; name=_functionBuilder
9696
// KEYWORD4-NEXT: End completions
9797

@@ -103,7 +103,7 @@ struct S{}
103103
// KEYWORD5-NEXT: Keyword/None: dynamicCallable[#Struct Attribute#]; name=dynamicCallable
104104
// KEYWORD5-NEXT: Keyword/None: dynamicMemberLookup[#Struct Attribute#]; name=dynamicMemberLookup
105105
// KEYWORD5-NEXT: Keyword/None: usableFromInline[#Struct Attribute#]; name=usableFromInline
106-
// KEYWORD5-NEXT: Keyword/None: _propertyWrapper[#Struct Attribute#]; name=_propertyWrapper
106+
// KEYWORD5-NEXT: Keyword/None: propertyWrapper[#Struct Attribute#]; name=propertyWrapper
107107
// KEYWORD5-NEXT: Keyword/None: _functionBuilder[#Struct Attribute#]; name=_functionBuilder
108108
// KEYWORD5-NEXT: End completions
109109

@@ -204,7 +204,7 @@ struct _S {
204204
// ON_MEMBER_LAST-DAG: Keyword/None: discardableResult[#Declaration Attribute#]; name=discardableResult
205205
// ON_MEMBER_LAST-DAG: Keyword/None: GKInspectable[#Declaration Attribute#]; name=GKInspectable
206206
// ON_MEMBER_LAST-DAG: Keyword/None: IBSegueAction[#Declaration Attribute#]; name=IBSegueAction
207-
// ON_MEMBER_LAST-DAG: Keyword/None: _propertyWrapper[#Declaration Attribute#]; name=_propertyWrapper
207+
// ON_MEMBER_LAST-DAG: Keyword/None: propertyWrapper[#Declaration Attribute#]; name=propertyWrapper
208208
// ON_MEMBER_LAST-DAG: Keyword/None: _functionBuilder[#Declaration Attribute#]; name=_functionBuilder
209209
// ON_MEMBER_LAST-NOT: Keyword
210210
// ON_MEMBER_LAST: Decl[Struct]/CurrModule: MyStruct[#MyStruct#]; name=MyStruct
@@ -236,7 +236,7 @@ struct _S {
236236
// KEYWORD_LAST-NEXT: Keyword/None: usableFromInline[#Declaration Attribute#]; name=usableFromInline{{$}}
237237
// KEYWORD_LAST-NEXT: Keyword/None: discardableResult[#Declaration Attribute#]; name=discardableResult
238238
// KEYWORD_LAST-NEXT: Keyword/None: GKInspectable[#Declaration Attribute#]; name=GKInspectable{{$}}
239-
// KEYWORD_LAST-NEXT: Keyword/None: _propertyWrapper[#Declaration Attribute#]; name=_propertyWrapper
239+
// KEYWORD_LAST-NEXT: Keyword/None: propertyWrapper[#Declaration Attribute#]; name=propertyWrapper
240240
// KEYWORD_LAST-NEXT: Keyword/None: _functionBuilder[#Declaration Attribute#]; name=_functionBuilder{{$}}
241241
// KEYWORD_LAST-NEXT: Keyword/None: IBSegueAction[#Declaration Attribute#]; name=IBSegueAction{{$}}
242242
// KEYWORD_LAST-NOT: Keyword

test/IDE/complete_property_delegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=SELF_VARNAME | %FileCheck %s -check-prefix=CONTEXT_VARNAME
77
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=SELF_DOLLAR_VARNAME | %FileCheck %s -check-prefix=CONTEXT_DOLLAR_VARNAME
88

9-
@_propertyWrapper
9+
@propertyWrapper
1010
struct Lazzzy<T> {
1111
var value: T
1212

test/IDE/complete_property_delegate_attribute.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ enum MyEnum {
66
case east, west
77
}
88

9-
@_propertyWrapper
9+
@propertyWrapper
1010
struct MyStruct {
1111
var value: MyEnum
1212
init(initialValue: MyEnum) {}

test/IDE/print_property_wrappers.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Directly printing the type-checked AST
44
// RUN: %target-swift-ide-test -print-ast-typechecked -source-filename %s | %FileCheck %s
55

6-
@_propertyWrapper
6+
@propertyWrapper
77
struct Wrapper<Value> {
88
var _stored: Value?
99

test/Index/property_wrappers.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %target-swift-ide-test -print-indexed-symbols -source-filename %s | %FileCheck -check-prefix=CHECK %s
22

3-
@_propertyWrapper
3+
@propertyWrapper
44
public struct Wrapper<T> {
55
public var value: T
66

test/ParseableInterface/property_wrappers.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
// RUN: %target-swift-frontend -build-module-from-parseable-interface -swift-version 5 %t/TestResilient.swiftinterface -o %t/TestResilient.swiftmodule
77
// RUN: %target-swift-frontend -emit-module -o /dev/null -merge-modules -swift-version 5 -emit-parseable-module-interface-path - %t/TestResilient.swiftmodule -module-name TestResilient | %FileCheck %s --check-prefix CHECK --check-prefix RESILIENT
88

9-
@_propertyWrapper
9+
@propertyWrapper
1010
public struct Wrapper<T> {
1111
public var value: T
1212
}
1313

14-
@_propertyWrapper
14+
@propertyWrapper
1515
public struct WrapperWithInitialValue<T> {
1616
public var value: T
1717

test/SILGen/property_wrappers.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// RUN: %target-swift-frontend -primary-file %s -emit-silgen | %FileCheck %s
22
// FIXME: switch to %target-swift-emit-silgen once we have syntax tree support
33

4-
@_propertyWrapper
4+
@propertyWrapper
55
struct Wrapper<T> {
66
var value: T
77
}
88

9-
@_propertyWrapper
9+
@propertyWrapper
1010
struct WrapperWithInitialValue<T> {
1111
var value: T
1212

@@ -107,7 +107,7 @@ func forceHasMemberwiseInit() {
107107
// CHECK: bb0:
108108
// CHECK: function_ref @$ss27_allocateUninitializedArrayySayxG_BptBwlF
109109
struct HasNested<T> {
110-
@_propertyWrapper
110+
@propertyWrapper
111111
private struct PrivateWrapper<U> {
112112
var value: U
113113
init(initialValue: U) {
@@ -180,7 +180,7 @@ struct WrapperWithDidSetWillSet {
180180
}
181181
}
182182

183-
@_propertyWrapper
183+
@propertyWrapper
184184
struct WrapperWithStorageValue<T> {
185185
var value: T
186186

@@ -201,7 +201,7 @@ struct UseWrapperWithStorageValue {
201201
}
202202
}
203203

204-
@_propertyWrapper
204+
@propertyWrapper
205205
enum Lazy<Value> {
206206
case uninitialized(() -> Value)
207207
case initialized(Value)
@@ -270,7 +270,7 @@ extension ClassUsingWrapper {
270270
}
271271

272272
//
273-
@_propertyWrapper
273+
@propertyWrapper
274274
struct WrapperWithDefaultInit<T> {
275275
private var storage: T?
276276

test/SILOptimizer/di_property_wrappers.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
// REQUIRES: executable_test
66

7-
@_propertyWrapper
7+
@propertyWrapper
88
struct Wrapper<T> {
99
var value: T {
1010
didSet {
@@ -304,7 +304,7 @@ func testGenericClass() {
304304
}
305305
}
306306

307-
@_propertyWrapper
307+
@propertyWrapper
308308
struct WrapperWithDefaultInit<Value> {
309309
private var _value: Value? = nil
310310

test/SILOptimizer/di_property_wrappers_errors.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %target-swift-frontend -emit-sil -verify %s
2-
@_propertyWrapper
2+
@propertyWrapper
33
final class ClassWrapper<T> {
44
var value: T {
55
didSet {

test/Serialization/Inputs/def_property_wrappers.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@_propertyWrapper
1+
@propertyWrapper
22
public struct SomeWrapper<T> {
33
public var value: T
44

@@ -12,7 +12,7 @@ public struct HasWrappers {
1212
}
1313

1414
// SR-10844
15-
@_propertyWrapper
15+
@propertyWrapper
1616
class A<T: Equatable> {
1717

1818
private var _value: T
@@ -27,7 +27,7 @@ class A<T: Equatable> {
2727
}
2828
}
2929

30-
@_propertyWrapper
30+
@propertyWrapper
3131
class B: A<Double> {
3232
override var value: Double {
3333
get { super.value }

test/decl/protocol/special/coding/property_wrappers_codable.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown
22

3-
@_propertyWrapper
3+
@propertyWrapper
44
struct Wrapper<T: Codable> {
55
var value: T
66
}
77

8-
@_propertyWrapper
8+
@propertyWrapper
99
struct WrapperWithInitialValue<T: Codable> {
1010
var value: T
1111

test/decl/var/property_wrapper_aliases.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// expect-no-diagnostics
44

5-
@propertyDelegate
5+
@propertyDelegate // expected-warning{{'@propertyDelegate' has been renamed to '@propertyWrapper'}}{{2-18=propertyWrapper}}
66
struct Delegate<T> {
77
var value: T
88

@@ -19,7 +19,7 @@ struct TestDelegateValue {
1919
}
2020
}
2121

22-
@propertyWrapper
22+
@_propertyWrapper // expected-warning{{'@_propertyWrapper' has been renamed to '@propertyWrapper'}}{{2-18=propertyWrapper}}
2323
struct Wrapper<T> {
2424
var value: T
2525
}

0 commit comments

Comments
 (0)