Skip to content

Commit b63e73e

Browse files
roopDougGregor
authored andcommitted
[Property wrappers] Rename hasPropertyWrapper() for clarity
GetterSetterComponent::hasPropertyWrapper() now checks for more stuff than just whether there's a property wrapper or not. It's therefore renamed to canRewriteSetAsPropertyWrapperInit().
1 parent 8ee83fd commit b63e73e

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/SILGen/SILGenLValue.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,7 @@ namespace {
13021302
{
13031303
}
13041304

1305-
bool hasPropertyWrapper() const {
1305+
bool canRewriteSetAsPropertyWrapperInit() const {
13061306
if (auto *VD = dyn_cast<VarDecl>(Storage)) {
13071307
// If this is not a wrapper property that can be initialized from
13081308
// a value of the wrapped type, we can't perform the initialization.
@@ -1396,9 +1396,8 @@ namespace {
13961396
assert(getAccessorDecl()->isSetter());
13971397
SILDeclRef setter = Accessor;
13981398

1399-
if (IsOnSelfParameter &&
1399+
if (IsOnSelfParameter && canRewriteSetAsPropertyWrapperInit() &&
14001400
!Storage->isStatic() &&
1401-
hasPropertyWrapper() &&
14021401
isBackingVarVisible(cast<VarDecl>(Storage),
14031402
SGF.FunctionDC)) {
14041403
// This is wrapped property. Instead of emitting a setter, emit an
@@ -4301,7 +4300,7 @@ static bool trySetterPeephole(SILGenFunction &SGF, SILLocation loc,
43014300
}
43024301

43034302
auto &setterComponent = static_cast<GetterSetterComponent&>(component);
4304-
if (setterComponent.hasPropertyWrapper())
4303+
if (setterComponent.canRewriteSetAsPropertyWrapperInit())
43054304
return false;
43064305
setterComponent.emitAssignWithSetter(SGF, loc, std::move(dest),
43074306
std::move(src));

0 commit comments

Comments
 (0)