Skip to content

Commit 40f0c43

Browse files
committed
Add isNativeDynamic() and use it
1 parent c3230df commit 40f0c43

File tree

7 files changed

+12
-9
lines changed

7 files changed

+12
-9
lines changed

include/swift/AST/Decl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2597,6 +2597,10 @@ class ValueDecl : public Decl {
25972597
return isObjC() && isDynamic();
25982598
}
25992599

2600+
bool isNativeDynamic() const {
2601+
return !isObjC() && isDynamic();
2602+
}
2603+
26002604
/// Set whether this type is 'dynamic' or not.
26012605
void setIsDynamic(bool value);
26022606

lib/AST/ASTVerifier.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3149,12 +3149,12 @@ class Verifier : public ASTWalker {
31493149
storageDecl->getWriteImpl() ==
31503150
WriteImplKind::StoredWithObservers ||
31513151
storageDecl->getWriteImpl() == WriteImplKind::MutableAddress) &&
3152-
storageDecl->isDynamic() && !storageDecl->isObjC()) &&
3152+
storageDecl->isNativeDynamic()) &&
31533153
// We allow a non dynamic getter if there is a dynamic read.
31543154
!(FD->isGetter() &&
31553155
(storageDecl->getReadImpl() == ReadImplKind::Read ||
31563156
storageDecl->getReadImpl() == ReadImplKind::Address) &&
3157-
storageDecl->isDynamic() && !storageDecl->isObjC())) {
3157+
storageDecl->isNativeDynamic())) {
31583158
Out << "Property and accessor do not match for 'dynamic'\n";
31593159
abort();
31603160
}

lib/AST/Decl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,7 +1549,7 @@ getDirectReadWriteAccessStrategy(const AbstractStorageDecl *storage) {
15491549
return AccessStrategy::getStorage();
15501550
case ReadWriteImplKind::Stored: {
15511551
// If the storage isDynamic (and not @objc) use the accessors.
1552-
if (storage->isDynamic() && !storage->isObjC())
1552+
if (storage->isNativeDynamic())
15531553
return AccessStrategy::getMaterializeToTemporary(
15541554
getOpaqueReadAccessStrategy(storage, false),
15551555
getOpaqueWriteAccessStrategy(storage, false));
@@ -1623,7 +1623,7 @@ AbstractStorageDecl::getAccessStrategy(AccessSemantics semantics,
16231623
if (isPolymorphic(this))
16241624
return getOpaqueAccessStrategy(this, accessKind, /*dispatch*/ true);
16251625

1626-
if (isDynamic())
1626+
if (isNativeDynamic())
16271627
return getOpaqueAccessStrategy(this, accessKind, /*dispatch*/ false);
16281628

16291629
// If the storage is resilient to the given use DC (perhaps because

lib/SIL/SILDeclRef.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -973,5 +973,5 @@ bool SILDeclRef::isDynamicallyReplaceable() const {
973973
return false;
974974

975975
auto decl = getDecl();
976-
return decl->isDynamic() && !decl->isObjC();
976+
return decl->isNativeDynamic();
977977
}

lib/Sema/CodeSynthesis.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2043,8 +2043,7 @@ void swift::maybeAddAccessorsToStorage(TypeChecker &TC,
20432043

20442044
if (!dc->isTypeContext()) {
20452045
// dynamic globals need accessors.
2046-
if (dc->isModuleScopeContext() && storage->isDynamic() &&
2047-
!storage->isObjC()) {
2046+
if (dc->isModuleScopeContext() && storage->isNativeDynamic()) {
20482047
addTrivialAccessorsToStorage(storage, TC);
20492048
return;
20502049
}

lib/Sema/TypeCheckAttr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2175,7 +2175,7 @@ void TypeChecker::checkDynamicReplacementAttribute(ValueDecl *D) {
21752175
return;
21762176
}
21772177

2178-
if (D->isDynamic() && !D->isObjC()) {
2178+
if (D->isNativeDynamic()) {
21792179
diagnose(attr->getLocation(), diag::dynamic_replacement_must_not_be_dynamic,
21802180
D->getBaseName());
21812181
attr->setInvalid();

lib/TBDGen/TBDGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ void TBDGenVisitor::visitAbstractFunctionDecl(AbstractFunctionDecl *AFD) {
165165
addSymbol(SILDeclRef(AFD));
166166

167167
// Add the global function pointer for a dynamically replaceable function.
168-
if (AFD->isDynamic() && ! AFD->isObjC()) {
168+
if (AFD->isNativeDynamic()) {
169169
addSymbol(LinkEntity::forDynamicallyReplaceableFunctionVariable(AFD));
170170
addSymbol(LinkEntity::forDynamicallyReplaceableFunctionImpl(AFD));
171171
addSymbol(LinkEntity::forDynamicallyReplaceableFunctionKey(AFD));

0 commit comments

Comments
 (0)