Skip to content

Commit d3f65e7

Browse files
committed
AST: Remove SubscriptDecl::isSettable()
1 parent 78c71c9 commit d3f65e7

File tree

10 files changed

+9
-16
lines changed

10 files changed

+9
-16
lines changed

include/swift/AST/Decl.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5489,9 +5489,6 @@ class SubscriptDecl : public GenericContext, public AbstractStorageDecl {
54895489
/// element types.
54905490
void computeType();
54915491

5492-
/// Returns whether the result of the subscript operation can be set.
5493-
bool isSettable() const;
5494-
54955492
/// Determine the kind of Objective-C subscripting this declaration
54965493
/// implies.
54975494
ObjCSubscriptKind getObjCSubscriptKind() const;
@@ -7107,7 +7104,7 @@ inline bool ValueDecl::isSettable(const DeclContext *UseDC,
71077104
if (auto vd = dyn_cast<VarDecl>(this)) {
71087105
return vd->isSettable(UseDC, base);
71097106
} else if (auto sd = dyn_cast<SubscriptDecl>(this)) {
7110-
return sd->isSettable();
7107+
return sd->supportsMutation();
71117108
} else
71127109
return false;
71137110
}

lib/AST/Decl.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5062,10 +5062,6 @@ bool VarDecl::isLazilyInitializedGlobal() const {
50625062
return !sourceFileContext->isScriptMode();
50635063
}
50645064

5065-
bool SubscriptDecl::isSettable() const {
5066-
return supportsMutation();
5067-
}
5068-
50695065
SourceRange VarDecl::getSourceRange() const {
50705066
if (auto Param = dyn_cast<ParamDecl>(this))
50715067
return Param->getSourceRange();

lib/ClangImporter/ImportDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6694,7 +6694,7 @@ SwiftDeclConverter::importSubscript(Decl *decl,
66946694
if (setter && existingSubscript && getterAndSetterInSameType) {
66956695
// Can we update the subscript by adding the setter?
66966696
if (existingSubscript->hasClangNode() &&
6697-
!existingSubscript->isSettable()) {
6697+
!existingSubscript->supportsMutation()) {
66986698
// Create the setter thunk.
66996699
auto setterThunk = buildSubscriptSetterDecl(
67006700
Impl, existingSubscript, setter, elementTy,

lib/IRGen/GenDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ class CategoryInitializerVisitor
242242
llvm::Value *getterArgs[] = {classMetadata, sel, imp, types};
243243
Builder.CreateCall(class_replaceMethod, getterArgs);
244244

245-
if (subscript->isSettable()) {
245+
if (subscript->supportsMutation()) {
246246
emitObjCSetterDescriptorParts(IGM, subscript,
247247
name, types, imp);
248248
sel = Builder.CreateCall(IGM.getObjCSelRegisterNameFn(),

lib/IRGen/GenObjC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,7 @@ SILFunction *irgen::emitObjCSetterDescriptorParts(IRGenModule &IGM,
12421242
llvm::Constant *&selectorRef,
12431243
llvm::Constant *&atEncoding,
12441244
llvm::Constant *&impl) {
1245-
assert(subscript->isSettable() && "not a settable subscript?!");
1245+
assert(subscript->supportsMutation() && "not a settable subscript?!");
12461246

12471247
Selector setterSel(subscript, Selector::ForSetter);
12481248
selectorRef = IGM.getAddrOfObjCMethodName(setterSel.str());

lib/Sema/CSDiag.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3662,7 +3662,7 @@ bool FailureDiagnosis::diagnoseSubscriptErrors(SubscriptExpr *SE,
36623662
// Classify how close this match is. Non-subscript decls don't match.
36633663
auto subscriptDecl = dyn_cast_or_null<SubscriptDecl>(cand.getDecl());
36643664
if (!subscriptDecl ||
3665-
(inAssignmentDestination && !subscriptDecl->isSettable()))
3665+
(inAssignmentDestination && !subscriptDecl->supportsMutation()))
36663666
return {CC_GeneralMismatch, {}};
36673667

36683668
// Check whether the self type matches.

lib/Sema/CSDiagnostics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,7 @@ bool AssignmentFailure::diagnoseAsError() {
14521452
// If the underlying expression was a read-only subscript, diagnose that.
14531453
if (auto *SD = dyn_cast_or_null<SubscriptDecl>(choice->getDecl())) {
14541454
StringRef message;
1455-
if (!SD->isSettable())
1455+
if (!SD->supportsMutation())
14561456
message = "subscript is get-only";
14571457
else if (!SD->isSetterAccessibleFrom(DC))
14581458
message = "subscript setter is inaccessible";

lib/Sema/TypeCheckDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2878,7 +2878,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
28782878
checkDynamicSelfType(SD, SD->getValueInterfaceType());
28792879

28802880
if (SD->getValueInterfaceType()->hasDynamicSelfType() &&
2881-
SD->isSettable()) {
2881+
SD->supportsMutation()) {
28822882
SD->diagnose(diag::dynamic_self_in_mutable_subscript);
28832883
}
28842884
}

lib/Serialization/Deserialization.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3859,7 +3859,7 @@ class swift::DeclDeserializer {
38593859
return nullptr;
38603860
}
38613861

3862-
if (subscript->isSettable()) {
3862+
if (subscript->supportsMutation()) {
38633863
if (auto setterAccess = getActualAccessLevel(rawSetterAccessLevel)) {
38643864
subscript->setSetterAccess(*setterAccess);
38653865
} else {

lib/Serialization/Serialization.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3649,7 +3649,7 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
36493649
uint8_t rawAccessLevel =
36503650
getRawStableAccessLevel(subscript->getFormalAccess());
36513651
uint8_t rawSetterAccessLevel = rawAccessLevel;
3652-
if (subscript->isSettable())
3652+
if (subscript->supportsMutation())
36533653
rawSetterAccessLevel =
36543654
getRawStableAccessLevel(subscript->getSetterFormalAccess());
36553655
uint8_t rawStaticSpelling =

0 commit comments

Comments
 (0)