Skip to content

Commit 5b3c181

Browse files
authored
Merge pull request swiftlang#25132 from DougGregor/property-wrappers-rename
2 parents 9571d46 + c02ecf9 commit 5b3c181

File tree

74 files changed

+1068
-1065
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1068
-1065
lines changed

docs/SIL.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2333,15 +2333,15 @@ with a sequence that also correctly destroys the current value.
23332333
This instruction is only valid in Raw SIL and is rewritten as appropriate
23342334
by the definitive initialization pass.
23352335

2336-
assign_by_delegate
2336+
assign_by_wrapper
23372337
``````````````````
23382338
::
23392339

2340-
sil-instruction ::= 'assign_by_delegate' sil-operand 'to' sil-operand ',' 'init' sil-operand ',' 'set' sil-operand
2340+
sil-instruction ::= 'assign_by_wrapper' sil-operand 'to' sil-operand ',' 'init' sil-operand ',' 'set' sil-operand
23412341

2342-
assign_by_delegate %0 : $S to %1 : $*T, init %2 : $F, set %3 : $G
2342+
assign_by_wrapper %0 : $S to %1 : $*T, init %2 : $F, set %3 : $G
23432343
// $S can be a value or address type
2344-
// $T must be the type of a property delegate.
2344+
// $T must be the type of a property wrapper.
23452345
// $F must be a function type, taking $S as a single argument and returning $T
23462346
// $G must be a function type, taking $S as a single argument and with not return value
23472347

include/swift/AST/ASTContext.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -838,11 +838,11 @@ class ASTContext final {
838838
const IterableDeclContext *idc,
839839
LazyMemberLoader *lazyLoader);
840840

841-
/// Access the side cache for property delegate backing property types,
841+
/// Access the side cache for property wrapper backing property types,
842842
/// used because TypeChecker::typeCheckBinding() needs somewhere to stash
843843
/// the backing property type.
844-
Type getSideCachedPropertyDelegateBackingPropertyType(VarDecl *var) const;
845-
void setSideCachedPropertyDelegateBackingPropertyType(VarDecl *var,
844+
Type getSideCachedPropertyWrapperBackingPropertyType(VarDecl *var) const;
845+
void setSideCachedPropertyWrapperBackingPropertyType(VarDecl *var,
846846
Type type);
847847

848848
/// Returns memory usage of this ASTContext.

include/swift/AST/ASTTypeIDZone.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
SWIFT_TYPEID_NAMED(NominalTypeDecl *, NominalTypeDecl)
1818
SWIFT_TYPEID_NAMED(VarDecl *, VarDecl)
1919
SWIFT_TYPEID(Type)
20-
SWIFT_TYPEID(PropertyDelegateBackingPropertyInfo)
21-
SWIFT_TYPEID(PropertyDelegateTypeInfo)
20+
SWIFT_TYPEID(PropertyWrapperBackingPropertyInfo)
21+
SWIFT_TYPEID(PropertyWrapperTypeInfo)
2222
SWIFT_TYPEID_NAMED(CustomAttr *, CustomAttr)
2323
SWIFT_TYPEID_NAMED(TypeAliasDecl *, TypeAliasDecl)

include/swift/AST/ASTTypeIDs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ namespace swift {
2222

2323
class CustomAttr;
2424
class NominalTypeDecl;
25-
struct PropertyDelegateBackingPropertyInfo;
26-
struct PropertyDelegateTypeInfo;
25+
struct PropertyWrapperBackingPropertyInfo;
26+
struct PropertyWrapperTypeInfo;
2727
class Type;
2828
class VarDecl;
2929
class TypeAliasDecl;

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(_propertyWrapper, PropertyWrapper,
403403
OnStruct | OnClass | OnEnum,
404404
86)
405405
SIMPLE_DECL_ATTR(_disfavoredOverload, DisfavoredOverload,

include/swift/AST/Decl.h

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ namespace swift {
7878
class ParameterTypeFlags;
7979
class Pattern;
8080
struct PrintOptions;
81-
struct PropertyDelegateBackingPropertyInfo;
82-
struct PropertyDelegateTypeInfo;
81+
struct PropertyWrapperBackingPropertyInfo;
82+
struct PropertyWrapperTypeInfo;
8383
class ProtocolDecl;
8484
class ProtocolType;
8585
struct RawComment;
@@ -391,8 +391,8 @@ class alignas(1 << DeclAlignInBits) Decl {
391391
/// FIXME: Remove this once LLDB has proper support for resilience.
392392
IsREPLVar : 1,
393393

394-
/// Whether this is the backing storage for a property delegate.
395-
IsPropertyDelegateBackingProperty : 1
394+
/// Whether this is the backing storage for a property wrapper.
395+
IsPropertyWrapperBackingProperty : 1
396396
);
397397

398398
SWIFT_INLINE_BITFIELD(ParamDecl, VarDecl, 1 + NumDefaultArgumentKindBits,
@@ -3394,8 +3394,8 @@ class NominalTypeDecl : public GenericTypeDecl, public IterableDeclContext {
33943394
/// Is this a key path type?
33953395
Optional<KeyPathTypeKind> getKeyPathTypeKind() const;
33963396

3397-
/// Retrieve information about this type as a property delegate.
3398-
PropertyDelegateTypeInfo getPropertyDelegateTypeInfo() const;
3397+
/// Retrieve information about this type as a property wrapper.
3398+
PropertyWrapperTypeInfo getPropertyWrapperTypeInfo() const;
33993399

34003400
private:
34013401
/// Predicate used to filter StoredPropertyRange.
@@ -4745,14 +4745,14 @@ class AbstractStorageDecl : public ValueDecl {
47454745
};
47464746

47474747
/// Describes which synthesized property for a property with an attached
4748-
/// delegate is being referenced.
4749-
enum class PropertyDelegateSynthesizedPropertyKind {
4748+
/// wrapper is being referenced.
4749+
enum class PropertyWrapperSynthesizedPropertyKind {
47504750
/// The backing storage property, which is a stored property of the
4751-
/// delegate type.
4751+
/// wrapper type.
47524752
Backing,
4753-
/// A storage delegate (e.g., `$foo`), which is a wrapper over the
4754-
/// delegate instance's `delegateValue` property.
4755-
StorageDelegate,
4753+
/// A storage wrapper (e.g., `$foo`), which is a wrapper over the
4754+
/// wrapper instance's `wrapperValue` property.
4755+
StorageWrapper,
47564756
};
47574757

47584758
/// VarDecl - 'var' and 'let' declarations.
@@ -4785,7 +4785,7 @@ class VarDecl : public AbstractStorageDecl {
47854785
Bits.VarDecl.IsDebuggerVar = false;
47864786
Bits.VarDecl.IsREPLVar = false;
47874787
Bits.VarDecl.HasNonPatternBindingInit = false;
4788-
Bits.VarDecl.IsPropertyDelegateBackingProperty = false;
4788+
Bits.VarDecl.IsPropertyWrapperBackingProperty = false;
47894789
}
47904790

47914791
/// This is the type specified, including location information.
@@ -5080,64 +5080,64 @@ class VarDecl : public AbstractStorageDecl {
50805080
Bits.VarDecl.IsREPLVar = IsREPLVar;
50815081
}
50825082

5083-
/// Retrieve the custom attribute that attaches a property delegate to this
5083+
/// Retrieve the custom attribute that attaches a property wrapper to this
50845084
/// property.
5085-
CustomAttr *getAttachedPropertyDelegate() const;
5085+
CustomAttr *getAttachedPropertyWrapper() const;
50865086

5087-
/// Retrieve the type of the attached property delegate as a contextual
5087+
/// Retrieve the type of the attached property wrapper as a contextual
50885088
/// type.
50895089
///
5090-
/// \returns a NULL type for properties without attached delegates,
5091-
/// an error type when the property delegate type itself is erroneous,
5092-
/// or the delegate type itself, which may involve unbound generic
5090+
/// \returns a NULL type for properties without attached wrappers,
5091+
/// an error type when the property wrapper type itself is erroneous,
5092+
/// or the wrapper type itself, which may involve unbound generic
50935093
/// types.
5094-
Type getAttachedPropertyDelegateType() const;
5094+
Type getAttachedPropertyWrapperType() const;
50955095

5096-
/// Retrieve information about the attached property delegate type.
5097-
PropertyDelegateTypeInfo getAttachedPropertyDelegateTypeInfo() const;
5096+
/// Retrieve information about the attached property wrapper type.
5097+
PropertyWrapperTypeInfo getAttachedPropertyWrapperTypeInfo() const;
50985098

5099-
/// Retrieve the fully resolved attached property delegate type.
5099+
/// Retrieve the fully resolved attached property wrapper type.
51005100
///
51015101
/// This type will be the fully-resolved form of
5102-
/// \c getAttachedPropertyDelegateType(), which will not contain any
5102+
/// \c getAttachedPropertyWrapperType(), which will not contain any
51035103
/// unbound generic types. It will be the type of the backing property.
5104-
Type getPropertyDelegateBackingPropertyType() const;
5104+
Type getPropertyWrapperBackingPropertyType() const;
51055105

51065106
/// Retrieve information about the backing properties of the attached
5107-
/// property delegate.
5108-
PropertyDelegateBackingPropertyInfo
5109-
getPropertyDelegateBackingPropertyInfo() const;
5107+
/// property wrapper.
5108+
PropertyWrapperBackingPropertyInfo
5109+
getPropertyWrapperBackingPropertyInfo() const;
51105110

51115111
/// Retrieve the backing storage property for a property that has an
5112-
/// attached property delegate.
5112+
/// attached property wrapper.
51135113
///
51145114
/// The backing storage property will be a stored property of the
5115-
/// delegate's type. This will be equivalent to
5116-
/// \c getAttachedPropertyDelegateType() when it is fully-specified;
5117-
/// if \c getAttachedPropertyDelegateType() involves an unbound
5115+
/// wrapper's type. This will be equivalent to
5116+
/// \c getAttachedPropertyWrapperType() when it is fully-specified;
5117+
/// if \c getAttachedPropertyWrapperType() involves an unbound
51185118
/// generic type, the backing storage property will be the appropriate
51195119
/// bound generic version.
5120-
VarDecl *getPropertyDelegateBackingProperty() const;
5120+
VarDecl *getPropertyWrapperBackingProperty() const;
51215121

5122-
/// Whether this is a property with a property delegate that was initialized
5122+
/// Whether this is a property with a property wrapper that was initialized
51235123
/// via a value of the original type, e.g.,
51245124
///
51255125
/// \code
51265126
/// @Lazy var i = 17
51275127
/// \end
5128-
bool isPropertyDelegateInitializedWithInitialValue() const;
5128+
bool isPropertyWrapperInitializedWithInitialValue() const;
51295129

51305130
/// If this property is the backing storage for a property with an attached
5131-
/// property delegate, return the original property.
5131+
/// property wrapper, return the original property.
51325132
///
51335133
/// \param kind If not \c None, only returns the original property when
51345134
/// \c this property is the specified synthesized property.
5135-
VarDecl *getOriginalDelegatedProperty(
5136-
Optional<PropertyDelegateSynthesizedPropertyKind> kind = None) const;
5135+
VarDecl *getOriginalWrappedProperty(
5136+
Optional<PropertyWrapperSynthesizedPropertyKind> kind = None) const;
51375137

5138-
/// Set the property that delegates to this property as it's backing
5138+
/// Set the property that wraps to this property as it's backing
51395139
/// property.
5140-
void setOriginalDelegatedProperty(VarDecl *originalProperty);
5140+
void setOriginalWrappedProperty(VarDecl *originalProperty);
51415141

51425142
/// Return the Objective-C runtime name for this property.
51435143
Identifier getObjCPropertyName() const;
@@ -5164,7 +5164,7 @@ class VarDecl : public AbstractStorageDecl {
51645164
/// initializer.
51655165
///
51665166
/// \param preferDeclaredProperties When encountering a `lazy` property
5167-
/// or a property that has an attached property delegate, prefer the
5167+
/// or a property that has an attached property wrapper, prefer the
51685168
/// actual declared property (which may or may not be considered "stored"
51695169
/// as the moment) to the backing storage property. Otherwise, the stored
51705170
/// backing property will be treated as the member-initialized property.

include/swift/AST/DiagnosticsSema.def

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4340,88 +4340,88 @@ WARNING(hashvalue_implementation,none,
43404340
(Type))
43414341

43424342
//------------------------------------------------------------------------------
4343-
// MARK: property delegate diagnostics
4343+
// MARK: property wrapper diagnostics
43444344
//------------------------------------------------------------------------------
4345-
ERROR(property_delegate_no_value_property, none,
4346-
"property delegate type %0 does not contain a non-static property "
4345+
ERROR(property_wrapper_no_value_property, none,
4346+
"property wrapper type %0 does not contain a non-static property "
43474347
"named %1", (Type, Identifier))
4348-
ERROR(property_delegate_ambiguous_value_property, none,
4349-
"property delegate type %0 has multiple non-static properties "
4348+
ERROR(property_wrapper_ambiguous_value_property, none,
4349+
"property wrapper type %0 has multiple non-static properties "
43504350
"named %1", (Type, Identifier))
4351-
ERROR(property_delegate_wrong_initial_value_init, none,
4351+
ERROR(property_wrapper_wrong_initial_value_init, none,
43524352
"'init(initialValue:)' parameter type (%0) must be the same as its "
43534353
"'value' property type (%1) or an @autoclosure thereof", (Type, Type))
4354-
ERROR(property_delegate_failable_init, none,
4354+
ERROR(property_wrapper_failable_init, none,
43554355
"%0 cannot be failable", (DeclName))
4356-
ERROR(property_delegate_ambiguous_initial_value_init, none,
4357-
"property delegate type %0 has multiple initial-value initializers", (Type))
4358-
ERROR(property_delegate_ambiguous_default_value_init, none,
4359-
"property delegate type %0 has multiple default-value initializers", (Type))
4360-
ERROR(property_delegate_type_requirement_not_accessible,none,
4356+
ERROR(property_wrapper_ambiguous_initial_value_init, none,
4357+
"property wrapper type %0 has multiple initial-value initializers", (Type))
4358+
ERROR(property_wrapper_ambiguous_default_value_init, none,
4359+
"property wrapper type %0 has multiple default-value initializers", (Type))
4360+
ERROR(property_wrapper_type_requirement_not_accessible,none,
43614361
"%select{private|fileprivate|internal|public|open}0 %1 %2 cannot have "
4362-
"more restrictive access than its enclosing property delegate type %3 "
4362+
"more restrictive access than its enclosing property wrapper type %3 "
43634363
"(which is %select{private|fileprivate|internal|public|open}4)",
43644364
(AccessLevel, DescriptiveDeclKind, DeclName, Type, AccessLevel))
4365-
ERROR(property_delegate_reserved_name,none,
4366-
"property delegate type name must start with an uppercase letter", ())
4365+
ERROR(property_wrapper_reserved_name,none,
4366+
"property wrapper type name must start with an uppercase letter", ())
43674367

4368-
ERROR(property_delegate_attribute_not_on_property, none,
4369-
"property delegate attribute %0 can only be applied to a property",
4368+
ERROR(property_wrapper_attribute_not_on_property, none,
4369+
"property wrapper attribute %0 can only be applied to a property",
43704370
(DeclName))
43714371

4372-
ERROR(property_delegate_multiple,none,
4373-
"only one property delegate can be attached to a given property", ())
4374-
NOTE(previous_property_delegate_here,none,
4375-
"previous property delegate specified here", ())
4372+
ERROR(property_wrapper_multiple,none,
4373+
"only one property wrapper can be attached to a given property", ())
4374+
NOTE(previous_property_wrapper_here,none,
4375+
"previous property wrapper specified here", ())
43764376

4377-
ERROR(property_delegate_local,none,
4378-
"property delegates are not yet supported on local properties", ())
4379-
ERROR(property_delegate_let, none,
4380-
"property delegate can only be applied to a 'var'",
4377+
ERROR(property_wrapper_local,none,
4378+
"property wrappers are not yet supported on local properties", ())
4379+
ERROR(property_wrapper_let, none,
4380+
"property wrapper can only be applied to a 'var'",
43814381
())
4382-
ERROR(property_delegate_computed, none,
4383-
"property delegate cannot be applied to a computed property",
4382+
ERROR(property_wrapper_computed, none,
4383+
"property wrapper cannot be applied to a computed property",
43844384
())
43854385

4386-
ERROR(property_with_delegate_conflict_attribute,none,
4387-
"property %0 with a delegate cannot also be "
4386+
ERROR(property_with_wrapper_conflict_attribute,none,
4387+
"property %0 with a wrapper cannot also be "
43884388
"%select{lazy|@NSCopying|@NSManaged|weak|unowned|unmanaged}1",
43894389
(DeclName, int))
4390-
ERROR(property_delegate_not_single_var, none,
4391-
"property delegate can only apply to a single variable", ())
4392-
ERROR(property_with_delegate_in_bad_context,none,
4390+
ERROR(property_wrapper_not_single_var, none,
4391+
"property wrapper can only apply to a single variable", ())
4392+
ERROR(property_with_wrapper_in_bad_context,none,
43934393
"%select{|non-static |non-static }1property %0 declared inside "
4394-
"%select{a protocol|an extension|an enum}1 cannot have a delegate",
4394+
"%select{a protocol|an extension|an enum}1 cannot have a wrapper",
43954395
(DeclName, int))
4396-
ERROR(property_with_delegate_overrides,none,
4397-
"property %0 with attached delegate cannot override another property",
4396+
ERROR(property_with_wrapper_overrides,none,
4397+
"property %0 with attached wrapper cannot override another property",
43984398
(DeclName))
43994399

4400-
ERROR(property_delegate_and_normal_init,none,
4401-
"property %0 with attached delegate cannot initialize both the "
4402-
"delegate type and the property", (DeclName))
4403-
ERROR(property_delegate_init_without_initial_value, none,
4404-
"initializing property %0 with delegate %1 that lacks "
4400+
ERROR(property_wrapper_and_normal_init,none,
4401+
"property %0 with attached wrapper cannot initialize both the "
4402+
"wrapper type and the property", (DeclName))
4403+
ERROR(property_wrapper_init_without_initial_value, none,
4404+
"initializing property %0 with wrapper %1 that lacks "
44054405
"an 'init(initialValue:)' initializer", (DeclName, Type))
4406-
NOTE(property_delegate_direct_init,none,
4407-
"initialize the property delegate type directly with "
4406+
NOTE(property_wrapper_direct_init,none,
4407+
"initialize the property wrapper type directly with "
44084408
"'(...') on the attribute", ())
44094409

4410-
ERROR(property_delegate_incompatible_unbound, none,
4411-
"property delegate type %0 must either specify all generic arguments "
4410+
ERROR(property_wrapper_incompatible_unbound, none,
4411+
"property wrapper type %0 must either specify all generic arguments "
44124412
"or require only a single generic argument", (Type))
44134413

4414-
ERROR(property_delegate_type_access,none,
4414+
ERROR(property_wrapper_type_access,none,
44154415
"%select{%select{variable|constant}0|property}1 "
44164416
"%select{must be declared %select{"
44174417
"%select{private|fileprivate|internal|%error|%error}3|private or fileprivate}4"
44184418
"|cannot be declared "
44194419
"%select{in this context|fileprivate|internal|public|open}3}2 "
4420-
"because its property delegate type uses "
4420+
"because its property wrapper type uses "
44214421
"%select{a private|a fileprivate|an internal|%error|%error}5 type",
44224422
(bool, bool, bool, AccessLevel, bool, AccessLevel))
4423-
ERROR(property_delegate_type_not_usable_from_inline,none,
4424-
"property delegate type referenced from a '@usableFromInline' "
4423+
ERROR(property_wrapper_type_not_usable_from_inline,none,
4424+
"property wrapper type referenced from a '@usableFromInline' "
44254425
"%select{%select{variable|constant}0|property}1 "
44264426
"must be '@usableFromInline' or public",
44274427
(bool, bool))

include/swift/AST/KnownIdentifiers.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ IDENTIFIER(WinSDK)
114114
IDENTIFIER(with)
115115
IDENTIFIER(withArguments)
116116
IDENTIFIER(withKeywordArguments)
117+
IDENTIFIER(wrapperValue)
117118

118119
// Kinds of layout constraints
119120
IDENTIFIER_WITH_NAME(UnknownLayout, "_UnknownLayout")

0 commit comments

Comments
 (0)