Skip to content

Commit 29caee2

Browse files
committed
Sema: Accessors of static members are always static
1 parent 48e4ddb commit 29caee2

File tree

4 files changed

+3
-16
lines changed

4 files changed

+3
-16
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1952,7 +1952,6 @@ static bool addErrorDomain(NominalTypeDecl *swiftDecl,
19521952
/*GenericParams=*/nullptr,
19531953
params,
19541954
TypeLoc::withoutLoc(stringTy), swiftDecl);
1955-
getterDecl->setStatic(isStatic);
19561955
getterDecl->computeType();
19571956
getterDecl->setIsObjC(false);
19581957
getterDecl->setIsDynamic(false);
@@ -1962,7 +1961,6 @@ static bool addErrorDomain(NominalTypeDecl *swiftDecl,
19621961
makeComputed(errorDomainPropertyDecl, getterDecl, nullptr);
19631962

19641963
getterDecl->setImplicit();
1965-
getterDecl->setStatic(isStatic);
19661964
getterDecl->setAccess(AccessLevel::Public);
19671965

19681966
llvm::PointerIntPair<ValueDecl *, 1, bool> contextData(swiftValueDecl,

lib/Sema/DerivedConformances.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,6 @@ addGetterToReadOnlyDerivedProperty(VarDecl *property,
292292
AccessorDecl *
293293
DerivedConformance::declareDerivedPropertyGetter(VarDecl *property,
294294
Type propertyContextType) {
295-
bool isStatic = property->isStatic();
296-
297295
auto &C = property->getASTContext();
298296
auto parentDC = property->getDeclContext();
299297
ParameterList *params = ParameterList::createEmpty(C);
@@ -308,7 +306,6 @@ DerivedConformance::declareDerivedPropertyGetter(VarDecl *property,
308306
/*GenericParams=*/nullptr, params,
309307
TypeLoc::withoutLoc(propertyInterfaceType), parentDC);
310308
getterDecl->setImplicit();
311-
getterDecl->setStatic(isStatic);
312309
getterDecl->setIsTransparent(false);
313310

314311
// Compute the interface type of the getter.

lib/Sema/TypeCheckDecl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,6 +1246,9 @@ IsFinalRequest::evaluate(Evaluator &evaluator, ValueDecl *decl) const {
12461246

12471247
llvm::Expected<bool>
12481248
IsStaticRequest::evaluate(Evaluator &evaluator, FuncDecl *decl) const {
1249+
if (auto *accessor = dyn_cast<AccessorDecl>(decl))
1250+
return accessor->getStorage()->isStatic();
1251+
12491252
bool result = (decl->getStaticLoc().isValid() ||
12501253
decl->getStaticSpelling() != StaticSpellingKind::None);
12511254
auto *dc = decl->getDeclContext();

lib/Sema/TypeCheckStorage.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,9 +1678,6 @@ static AccessorDecl *createGetterPrototype(AbstractStorageDecl *storage,
16781678
else
16791679
getter->setSelfAccessKind(SelfAccessKind::NonMutating);
16801680

1681-
if (storage->isStatic())
1682-
getter->setStatic();
1683-
16841681
if (!storage->requiresOpaqueAccessor(AccessorKind::Get))
16851682
getter->setForcedStaticDispatch(true);
16861683

@@ -1696,7 +1693,6 @@ static AccessorDecl *createSetterPrototype(AbstractStorageDecl *storage,
16961693

16971694
SourceLoc loc = storage->getLoc();
16981695

1699-
bool isStatic = storage->isStatic();
17001696
bool isMutating = storage->isSetterMutating();
17011697

17021698
GenericParamList *genericParams = createAccessorGenericParams(storage);
@@ -1725,9 +1721,6 @@ static AccessorDecl *createSetterPrototype(AbstractStorageDecl *storage,
17251721
else
17261722
setter->setSelfAccessKind(SelfAccessKind::NonMutating);
17271723

1728-
if (isStatic)
1729-
setter->setStatic();
1730-
17311724
// All mutable storage requires a setter.
17321725
assert(storage->requiresOpaqueAccessor(AccessorKind::Set));
17331726

@@ -1744,7 +1737,6 @@ createCoroutineAccessorPrototype(AbstractStorageDecl *storage,
17441737

17451738
SourceLoc loc = storage->getLoc();
17461739

1747-
bool isStatic = storage->isStatic();
17481740
bool isMutating = storage->isGetterMutating();
17491741
if (kind == AccessorKind::Modify)
17501742
isMutating |= storage->isSetterMutating();
@@ -1771,9 +1763,6 @@ createCoroutineAccessorPrototype(AbstractStorageDecl *storage,
17711763
else
17721764
accessor->setSelfAccessKind(SelfAccessKind::NonMutating);
17731765

1774-
if (isStatic)
1775-
accessor->setStatic();
1776-
17771766
// If the storage does not provide this accessor as an opaque accessor,
17781767
// we can't add a dynamically-dispatched method entry for the accessor,
17791768
// so force it to be statically dispatched. ("final" would be inappropriate

0 commit comments

Comments
 (0)