Skip to content

Commit d282e3c

Browse files
committed
[Property wrappers] NFC rename initialValue -> wrappedValue where appropriate
wrappedValue is the new name, and we only support initialValue for backward compatibility with earlier revisions of the property wrappers proposal.
1 parent 5ac8d76 commit d282e3c

File tree

6 files changed

+18
-15
lines changed

6 files changed

+18
-15
lines changed

include/swift/AST/Decl.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5119,15 +5119,17 @@ class VarDecl : public AbstractStorageDecl {
51195119
void setTopLevelGlobal(bool b) { Bits.VarDecl.IsTopLevelGlobal = b; }
51205120

51215121
/// Retrieve the custom attributes that attach property wrappers to this
5122-
/// property. The returned list contains all of the attached property wrapper attributes in source order,
5123-
/// which means the outermost wrapper attribute is provided first.
5122+
/// property. The returned list contains all of the attached property wrapper
5123+
/// attributes in source order, which means the outermost wrapper attribute
5124+
/// is provided first.
51245125
llvm::TinyPtrVector<CustomAttr *> getAttachedPropertyWrappers() const;
51255126

51265127
/// Whether this property has any attached property wrappers.
51275128
bool hasAttachedPropertyWrapper() const;
51285129

5129-
/// Whether all of the attached property wrappers have an init(initialValue:) initializer.
5130-
bool allAttachedPropertyWrappersHaveInitialValueInit() const;
5130+
/// Whether all of the attached property wrappers have an init(wrappedValue:)
5131+
/// initializer.
5132+
bool allAttachedPropertyWrappersHaveWrappedValueInit() const;
51315133

51325134
/// Retrieve the type of the attached property wrapper as a contextual
51335135
/// type.
@@ -5191,7 +5193,7 @@ class VarDecl : public AbstractStorageDecl {
51915193
/// \end
51925194
///
51935195
/// Or when there is no initializer but each composed property wrapper has
5194-
/// a suitable `init(initialValue:)`.
5196+
/// a suitable `init(wrappedValue:)`.
51955197
bool isPropertyMemberwiseInitializedWithWrappedType() const;
51965198

51975199
/// Whether the innermost property wrapper's initializer's 'wrappedValue' parameter

lib/AST/Decl.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,11 +1878,11 @@ bool PatternBindingDecl::isDefaultInitializable(unsigned i) const {
18781878
if (isDefaultInitializableViaPropertyWrapper(i))
18791879
return true;
18801880

1881-
// If one of the attached wrappers is missing an initialValue
1881+
// If one of the attached wrappers is missing a wrappedValue
18821882
// initializer, cannot default-initialize.
18831883
if (auto singleVar = getSingleVar()) {
18841884
if (auto wrapperInfo = singleVar->getAttachedPropertyWrapperTypeInfo(0)) {
1885-
if (!singleVar->allAttachedPropertyWrappersHaveInitialValueInit())
1885+
if (!singleVar->allAttachedPropertyWrappersHaveWrappedValueInit())
18861886
return false;
18871887
}
18881888
}
@@ -5833,7 +5833,7 @@ bool VarDecl::hasAttachedPropertyWrapper() const {
58335833

58345834
/// Whether all of the attached property wrappers have an init(wrappedValue:)
58355835
/// initializer.
5836-
bool VarDecl::allAttachedPropertyWrappersHaveInitialValueInit() const {
5836+
bool VarDecl::allAttachedPropertyWrappersHaveWrappedValueInit() const {
58375837
for (unsigned i : indices(getAttachedPropertyWrappers())) {
58385838
if (!getAttachedPropertyWrapperTypeInfo(i).wrappedValueInit)
58395839
return false;
@@ -5938,7 +5938,7 @@ bool VarDecl::isPropertyMemberwiseInitializedWithWrappedType() const {
59385938

59395939
// If all property wrappers have a wrappedValue initializer, the property
59405940
// wrapper will be initialized that way.
5941-
return allAttachedPropertyWrappersHaveInitialValueInit();
5941+
return allAttachedPropertyWrappersHaveWrappedValueInit();
59425942
}
59435943

59445944
bool VarDecl::isInnermostPropertyWrapperInitUsesEscapingAutoClosure() const {

lib/Sema/ConstraintSystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4182,7 +4182,7 @@ void SolutionApplicationTarget::maybeApplyPropertyWrapper() {
41824182
if (Expr *initializer = expression.expression) {
41834183
// Form init(wrappedValue:) call(s).
41844184
Expr *wrappedInitializer =
4185-
buildPropertyWrapperInitialValueCall(
4185+
buildPropertyWrapperWrappedValueCall(
41864186
singleVar, Type(), initializer, /*ignoreAttributeArgs=*/false);
41874187
if (!wrappedInitializer)
41884188
return;

lib/Sema/TypeCheckPropertyWrapper.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ using namespace swift;
2828

2929
/// The kind of property initializer to look for
3030
enum class PropertyWrapperInitKind {
31-
/// An initial-value initializer (i.e. `init(initialValue:)`)
31+
/// An initial-value initializer (i.e. `init(initialValue:)`), which is
32+
/// deprecated.
3233
InitialValue,
3334
/// An wrapped-value initializer (i.e. `init(wrappedValue:)`)
3435
WrappedValue,
@@ -684,7 +685,7 @@ static bool isOpaquePlaceholderClosure(const Expr *value) {
684685
return false;
685686
}
686687

687-
Expr *swift::buildPropertyWrapperInitialValueCall(
688+
Expr *swift::buildPropertyWrapperWrappedValueCall(
688689
VarDecl *var, Type backingStorageType, Expr *value,
689690
bool ignoreAttributeArgs) {
690691
// From the innermost wrapper type out, form init(wrapperValue:) calls.

lib/Sema/TypeCheckStorage.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2463,7 +2463,7 @@ PropertyWrapperBackingPropertyInfoRequest::evaluate(Evaluator &evaluator,
24632463
}
24642464

24652465
// Get the property wrapper information.
2466-
if (!var->allAttachedPropertyWrappersHaveInitialValueInit() &&
2466+
if (!var->allAttachedPropertyWrappersHaveWrappedValueInit() &&
24672467
!originalInitialValue) {
24682468
return PropertyWrapperBackingPropertyInfo(
24692469
backingVar, storageVar, nullptr, nullptr, nullptr);
@@ -2477,7 +2477,7 @@ PropertyWrapperBackingPropertyInfoRequest::evaluate(Evaluator &evaluator,
24772477
OpaqueValueExpr *origValue =
24782478
new (ctx) OpaqueValueExpr(var->getSourceRange(), origValueType,
24792479
/*isPlaceholder=*/true);
2480-
Expr *initializer = buildPropertyWrapperInitialValueCall(
2480+
Expr *initializer = buildPropertyWrapperWrappedValueCall(
24812481
var, storageType, origValue,
24822482
/*ignoreAttributeArgs=*/!originalInitialValue);
24832483
typeCheckSynthesizedWrapperInitializer(

lib/Sema/TypeChecker.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1486,7 +1486,7 @@ Type computeWrappedValueType(VarDecl *var, Type backingStorageType,
14861486

14871487
/// Build a call to the init(wrappedValue:) initializers of the property
14881488
/// wrappers, filling in the given \c value as the original value.
1489-
Expr *buildPropertyWrapperInitialValueCall(VarDecl *var,
1489+
Expr *buildPropertyWrapperWrappedValueCall(VarDecl *var,
14901490
Type backingStorageType,
14911491
Expr *value,
14921492
bool ignoreAttributeArgs);

0 commit comments

Comments
 (0)