Skip to content

Commit 0c26e43

Browse files
committed
Underscore the @propertyDelegate attribute to indicate that it's experimental
1 parent 6218673 commit 0c26e43

10 files changed

+44
-44
lines changed

include/swift/AST/Attr.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ SIMPLE_DECL_ATTR(_implementationOnly, ImplementationOnly,
399399
DECL_ATTR(_custom, Custom,
400400
OnAnyDecl | UserInaccessible,
401401
85)
402-
SIMPLE_DECL_ATTR(propertyDelegate, PropertyDelegate,
402+
SIMPLE_DECL_ATTR(_propertyDelegate, PropertyDelegate,
403403
OnStruct | OnClass | OnEnum,
404404
86)
405405

lib/Sema/TypeCheckPropertyDelegate.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ static ConstructorDecl *findInitialValueInit(ASTContext &ctx,
170170
llvm::Expected<PropertyDelegateTypeInfo>
171171
PropertyDelegateTypeInfoRequest::evaluate(
172172
Evaluator &eval, NominalTypeDecl *nominal) const {
173-
// We must have the @propertyDelegate attribute to continue.
173+
// We must have the @_propertyDelegate attribute to continue.
174174
if (!nominal->getAttrs().hasAttribute<PropertyDelegateAttr>()) {
175175
return PropertyDelegateTypeInfo();
176176
}
@@ -203,7 +203,7 @@ AttachedPropertyDelegateRequest::evaluate(Evaluator &evaluator,
203203
auto nominal = evaluateOrDefault(
204204
ctx.evaluator, CustomAttrNominalRequest{mutableAttr, dc}, nullptr);
205205

206-
// If we didn't find a nominal type with a @propertyDelegate attribute,
206+
// If we didn't find a nominal type with a @_propertyDelegate attribute,
207207
// skip this custom attribute.
208208
if (!nominal || !nominal->getAttrs().hasAttribute<PropertyDelegateAttr>())
209209
continue;

test/IDE/complete_decl_attribute.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class C {}
6666
// KEYWORD3-NEXT: Keyword/None: objcMembers[#Class Attribute#]; name=objcMembers{{$}}
6767
// KEYWORD3-NEXT: Keyword/None: NSApplicationMain[#Class Attribute#]; name=NSApplicationMain{{$}}
6868
// KEYWORD3-NEXT: Keyword/None: usableFromInline[#Class Attribute#]; name=usableFromInline
69-
// KEYWORD3-NEXT: Keyword/None: propertyDelegate[#Class Attribute#]; name=propertyDelegate
69+
// KEYWORD3-NEXT: Keyword/None: _propertyDelegate[#Class Attribute#]; name=_propertyDelegate
7070
// KEYWORD3-NEXT: End completions
7171

7272
@#^KEYWORD3_2^#IB
@@ -81,7 +81,7 @@ enum E {}
8181
// KEYWORD4-NEXT: Keyword/None: dynamicCallable[#Enum Attribute#]; name=dynamicCallable
8282
// KEYWORD4-NEXT: Keyword/None: dynamicMemberLookup[#Enum Attribute#]; name=dynamicMemberLookup
8383
// KEYWORD4-NEXT: Keyword/None: usableFromInline[#Enum Attribute#]; name=usableFromInline
84-
// KEYWORD4-NEXT: Keyword/None: propertyDelegate[#Enum Attribute#]; name=propertyDelegate
84+
// KEYWORD4-NEXT: Keyword/None: _propertyDelegate[#Enum Attribute#]; name=_propertyDelegate
8585
// KEYWORD4-NEXT: End completions
8686

8787

@@ -92,7 +92,7 @@ struct S{}
9292
// KEYWORD5-NEXT: Keyword/None: dynamicCallable[#Struct Attribute#]; name=dynamicCallable
9393
// KEYWORD5-NEXT: Keyword/None: dynamicMemberLookup[#Struct Attribute#]; name=dynamicMemberLookup
9494
// KEYWORD5-NEXT: Keyword/None: usableFromInline[#Struct Attribute#]; name=usableFromInline
95-
// KEYWORD5-NEXT: Keyword/None: propertyDelegate[#Struct Attribute#]; name=propertyDelegate
95+
// KEYWORD5-NEXT: Keyword/None: _propertyDelegate[#Struct Attribute#]; name=_propertyDelegate
9696
// KEYWORD5-NEXT: End completions
9797

9898

@@ -120,5 +120,5 @@ struct S{}
120120
// KEYWORD_LAST-NEXT: Keyword/None: usableFromInline[#Declaration Attribute#]; name=usableFromInline{{$}}
121121
// KEYWORD_LAST-NEXT: Keyword/None: discardableResult[#Declaration Attribute#]; name=discardableResult
122122
// KEYWORD_LAST-NEXT: Keyword/None: GKInspectable[#Declaration Attribute#]; name=GKInspectable{{$}}
123-
// KEYWORD_LAST-NEXT: Keyword/None: propertyDelegate[#Declaration Attribute#]; name=propertyDelegate
123+
// KEYWORD_LAST-NEXT: Keyword/None: _propertyDelegate[#Declaration Attribute#]; name=_propertyDelegate
124124
// KEYWORD_LAST-NEXT: End completions

test/IDE/print_property_delegates.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-
@propertyDelegate
6+
@_propertyDelegate
77
struct Delegate<Value> {
88
var value: Value
99

test/Index/property_delegates.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-
@propertyDelegate
3+
@_propertyDelegate
44
public struct Wrapper<T> {
55
public var value: T
66

test/SILGen/property_delegates.swift

Lines changed: 5 additions & 5 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-
@propertyDelegate
4+
@_propertyDelegate
55
struct Wrapper<T> {
66
var value: T
77
}
88

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

@@ -111,7 +111,7 @@ func forceHasMemberwiseInit() {
111111
// CHECK: [[DELEGATE_VALUE:%.*]] = load [take] [[STACK_SLOT]] : $*HasNested<T>.PrivateDelegate<Array<T>>
112112
// CHECK: struct $HasNested<T> ([[DELEGATE_VALUE]] : $HasNested<T>.PrivateDelegate<Array<T>>)
113113
struct HasNested<T> {
114-
@propertyDelegate
114+
@_propertyDelegate
115115
private struct PrivateDelegate<U> {
116116
var value: U
117117
init(initialValue: U) {
@@ -189,7 +189,7 @@ struct DelegateWithDidSetWillSet {
189189
}
190190
}
191191

192-
@propertyDelegate
192+
@_propertyDelegate
193193
struct WrapperWithStorageValue<T> {
194194
var value: T
195195

@@ -206,7 +206,7 @@ struct UseWrapperWithStorageValue {
206206
@WrapperWithStorageValue(value: 17) var x: Int
207207
}
208208

209-
@propertyDelegate
209+
@_propertyDelegate
210210
enum Lazy<Value> {
211211
case uninitialized(() -> Value)
212212
case initialized(Value)

test/SILOptimizer/di-property-delegates-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-
@propertyDelegate
2+
@_propertyDelegate
33
final class ClassWrapper<T> {
44
var value: T {
55
didSet {

test/SILOptimizer/di-property-delegates.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
// REQUIRES: executable_test
66

7-
@propertyDelegate
7+
@_propertyDelegate
88
struct Wrapper<T> {
99
var value: T {
1010
didSet {

test/decl/var/property_delegates.swift

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
// ---------------------------------------------------------------------------
44
// Property delegate type definitions
55
// ---------------------------------------------------------------------------
6-
@propertyDelegate
6+
@_propertyDelegate
77
struct Wrapper<T> {
88
var value: T
99
}
1010

11-
@propertyDelegate
11+
@_propertyDelegate
1212
struct WrapperWithInitialValue<T> {
1313
var value: T
1414

@@ -17,7 +17,7 @@ struct WrapperWithInitialValue<T> {
1717
}
1818
}
1919

20-
@propertyDelegate
20+
@_propertyDelegate
2121
struct WrapperAcceptingAutoclosure<T> {
2222
private let fn: () -> T
2323

@@ -34,30 +34,30 @@ struct WrapperAcceptingAutoclosure<T> {
3434
}
3535
}
3636

37-
@propertyDelegate
37+
@_propertyDelegate
3838
struct MissingValue<T> { }
3939
// expected-error@-1{{property delegate type 'MissingValue' does not contain a non-static property named 'value'}}
4040

41-
@propertyDelegate
41+
@_propertyDelegate
4242
struct StaticValue {
4343
static var value: Int = 17
4444
}
4545
// expected-error@-3{{property delegate type 'StaticValue' does not contain a non-static property named 'value'}}
4646

4747

48-
// expected-error@+1{{'@propertyDelegate' attribute cannot be applied to this declaration}}
49-
@propertyDelegate
48+
// expected-error@+1{{'@_propertyDelegate' attribute cannot be applied to this declaration}}
49+
@_propertyDelegate
5050
protocol CannotBeADelegate {
5151
associatedtype Value
5252
var value: Value { get set }
5353
}
5454

55-
@propertyDelegate
55+
@_propertyDelegate
5656
struct NonVisibleValueDelegate<Value> {
5757
private var value: Value // expected-error{{private property 'value' cannot have more restrictive access than its enclosing property delegate type 'NonVisibleValueDelegate' (which is internal)}}
5858
}
5959

60-
@propertyDelegate
60+
@_propertyDelegate
6161
struct NonVisibleInitDelegate<Value> {
6262
var value: Value
6363

@@ -66,7 +66,7 @@ struct NonVisibleInitDelegate<Value> {
6666
}
6767
}
6868

69-
@propertyDelegate
69+
@_propertyDelegate
7070
struct InitialValueTypeMismatch<Value> {
7171
var value: Value // expected-note{{'value' declared here}}
7272

@@ -75,7 +75,7 @@ struct InitialValueTypeMismatch<Value> {
7575
}
7676
}
7777

78-
@propertyDelegate
78+
@_propertyDelegate
7979
struct MultipleInitialValues<Value> { // expected-error{{property delegate type 'MultipleInitialValues' has multiple initial-value initializers}}
8080
var value: Value? = nil
8181

@@ -86,7 +86,7 @@ struct MultipleInitialValues<Value> { // expected-error{{property delegate type
8686
}
8787
}
8888

89-
@propertyDelegate
89+
@_propertyDelegate
9090
struct InitialValueFailable<Value> {
9191
var value: Value
9292

@@ -95,7 +95,7 @@ struct InitialValueFailable<Value> {
9595
}
9696
}
9797

98-
@propertyDelegate
98+
@_propertyDelegate
9999
struct InitialValueFailableIUO<Value> {
100100
var value: Value
101101

@@ -107,12 +107,12 @@ struct InitialValueFailableIUO<Value> {
107107
// ---------------------------------------------------------------------------
108108
// Property delegate type definitions
109109
// ---------------------------------------------------------------------------
110-
@propertyDelegate
110+
@_propertyDelegate
111111
struct _lowercaseDelegate<T> { // expected-error{{property delegate type name must start with an uppercase letter}}
112112
var value: T
113113
}
114114

115-
@propertyDelegate
115+
@_propertyDelegate
116116
struct _UppercaseDelegate<T> {
117117
var value: T
118118
}
@@ -228,17 +228,17 @@ struct Initialization {
228228
// ---------------------------------------------------------------------------
229229
// Delegate type formation
230230
// ---------------------------------------------------------------------------
231-
@propertyDelegate
231+
@_propertyDelegate
232232
struct IntWrapper {
233233
var value: Int
234234
}
235235

236-
@propertyDelegate
236+
@_propertyDelegate
237237
struct WrapperForHashable<T: Hashable> {
238238
var value: T
239239
}
240240

241-
@propertyDelegate
241+
@_propertyDelegate
242242
struct WrapperWithTwoParams<T, U> {
243243
var value: (T, U)
244244
}
@@ -270,7 +270,7 @@ struct UseWrappersWithDifferentForm {
270270
// Nested delegates
271271
// ---------------------------------------------------------------------------
272272
struct HasNestedDelegate<T> {
273-
@propertyDelegate
273+
@_propertyDelegate
274274
struct NestedDelegate<U> {
275275
var value: U
276276
init(initialValue: U) {
@@ -367,7 +367,7 @@ struct UseWillSetDidSet {
367367
// ---------------------------------------------------------------------------
368368
// Mutating/nonmutating
369369
// ---------------------------------------------------------------------------
370-
@propertyDelegate
370+
@_propertyDelegate
371371
struct DelegateWithNonMutatingSetter<Value> {
372372
class Box {
373373
var value: Value
@@ -388,7 +388,7 @@ struct DelegateWithNonMutatingSetter<Value> {
388388
}
389389
}
390390

391-
@propertyDelegate
391+
@_propertyDelegate
392392
struct DelegateWithMutatingGetter<Value> {
393393
var readCount = 0
394394
var writeCount = 0
@@ -410,7 +410,7 @@ struct DelegateWithMutatingGetter<Value> {
410410
}
411411
}
412412

413-
@propertyDelegate
413+
@_propertyDelegate
414414
class ClassDelegate<Value> {
415415
var value: Value
416416

@@ -469,7 +469,7 @@ func testMutatingness() {
469469
// Access control
470470
// ---------------------------------------------------------------------------
471471
struct HasPrivateDelegate<T> {
472-
@propertyDelegate
472+
@_propertyDelegate
473473
private struct PrivateDelegate<U> { // expected-note{{type declared here}}
474474
var value: U
475475
init(initialValue: U) {
@@ -487,7 +487,7 @@ struct HasPrivateDelegate<T> {
487487
}
488488

489489
public struct HasUsableFromInlineDelegate<T> {
490-
@propertyDelegate
490+
@_propertyDelegate
491491
struct InternalDelegate<U> { // expected-note{{type declared here}}
492492
var value: U
493493
init(initialValue: U) {
@@ -501,7 +501,7 @@ public struct HasUsableFromInlineDelegate<T> {
501501
// expected-error@-1{{property delegate type referenced from a '@usableFromInline' property must be '@usableFromInline' or public}}
502502
}
503503

504-
@propertyDelegate
504+
@_propertyDelegate
505505
class Box<Value> {
506506
private(set) var value: Value
507507

@@ -613,7 +613,7 @@ func testDefaultInitializers() {
613613
// ---------------------------------------------------------------------------
614614
// Storage references
615615
// ---------------------------------------------------------------------------
616-
@propertyDelegate
616+
@_propertyDelegate
617617
struct WrapperWithStorageRef<T> {
618618
var value: T
619619

@@ -652,7 +652,7 @@ func testStorageRef(tsr: TestStorageRef) {
652652
// ---------------------------------------------------------------------------
653653
// Misc. semantic issues
654654
// ---------------------------------------------------------------------------
655-
@propertyDelegate
655+
@_propertyDelegate
656656
struct BrokenLazy { }
657657
// expected-error@-1{{property delegate type 'BrokenLazy' does not contain a non-static property named 'value'}}
658658
// expected-note@-2{{'BrokenLazy' declared here}}

test/decl/var/property_delegates_synthesis.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %target-swift-frontend -typecheck -dump-ast %s | %FileCheck %s
22

3-
@propertyDelegate
3+
@_propertyDelegate
44
struct Wrapper<T> {
55
var value: T
66

0 commit comments

Comments
 (0)