Skip to content

Commit a9aad0f

Browse files
committed
Don't add implicit dynamic to variables to local and implicit vars
1 parent af13914 commit a9aad0f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2457,6 +2457,21 @@ void TypeChecker::addImplicitDynamicAttribute(Decl *D) {
24572457
isa<AccessorDecl>(D))
24582458
return;
24592459

2460+
if (D->getAttrs().hasAttribute<FinalAttr>() ||
2461+
D->getAttrs().hasAttribute<NonObjCAttr>() ||
2462+
D->getAttrs().hasAttribute<TransparentAttr>() ||
2463+
D->getAttrs().hasAttribute<InlinableAttr>())
2464+
return;
2465+
2466+
if (auto *VD = dyn_cast<VarDecl>(D)) {
2467+
// Don't add dynamic to local variables.
2468+
if (VD->getDeclContext()->isLocalContext())
2469+
return;
2470+
// Don't add to implicit variables.
2471+
if (VD->isImplicit())
2472+
return;
2473+
}
2474+
24602475
if (!D->getAttrs().hasAttribute<DynamicAttr>() &&
24612476
!D->getAttrs().hasAttribute<DynamicReplacementAttr>()) {
24622477
auto attr = new (D->getASTContext()) DynamicAttr(/*implicit=*/true);

0 commit comments

Comments
 (0)