Skip to content

Commit cd724d4

Browse files
authored
Merge pull request #35988 from slavapestov/simplify-does-storage-produce-lvalue
Sema: Simplify doesStorageProduceLValue() a bit
2 parents 08205ec + 0865dc1 commit cd724d4

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,27 +1019,16 @@ static bool doesStorageProduceLValue(AbstractStorageDecl *storage,
10191019
if (!storage->isSetterAccessibleFrom(useDC))
10201020
return false;
10211021

1022-
// If there is no base, or if the base isn't being used, it is settable.
1023-
// This is only possible for vars.
1024-
if (auto var = dyn_cast<VarDecl>(storage)) {
1025-
if (!baseType || var->isStatic())
1026-
return true;
1027-
}
1028-
1029-
// If the base is an lvalue, then a reference produces an lvalue.
1030-
if (baseType->is<LValueType>())
1031-
return true;
1032-
1033-
// Stored properties of reference types produce lvalues.
1034-
if (baseType->hasReferenceSemantics() && storage->hasStorage())
1022+
// If there is no base, or the base is an lvalue, then a reference
1023+
// produces an lvalue.
1024+
if (!baseType || baseType->is<LValueType>())
10351025
return true;
10361026

1037-
// So the base is an rvalue type. The only way an accessor can
1027+
// The base is an rvalue type. The only way an accessor can
10381028
// produce an lvalue is if we have a property where both the
10391029
// getter and setter are nonmutating.
1040-
return !storage->hasStorage() &&
1041-
!storage->isGetterMutating() &&
1042-
!storage->isSetterMutating();
1030+
return (!storage->isGetterMutating() &&
1031+
!storage->isSetterMutating());
10431032
}
10441033

10451034
Type ConstraintSystem::getUnopenedTypeOfReference(VarDecl *value, Type baseType,

0 commit comments

Comments
 (0)