Skip to content

Commit 2c0c596

Browse files
committed
[ASTScope] Add attribute scopes for nominal type and extension scopes.
1 parent abcdc6c commit 2c0c596

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

include/swift/AST/ASTScope.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -849,9 +849,9 @@ class DefaultArgumentInitializerScope final : public ASTScopeImpl {
849849
class CustomAttributeScope final : public ASTScopeImpl {
850850
public:
851851
CustomAttr *attr;
852-
ValueDecl *decl;
852+
Decl *decl;
853853

854-
CustomAttributeScope(CustomAttr *attr, ValueDecl *decl)
854+
CustomAttributeScope(CustomAttr *attr,Decl *decl)
855855
: attr(attr), decl(decl) {}
856856
virtual ~CustomAttributeScope() {}
857857

@@ -1130,9 +1130,9 @@ class SpecializeAttributeScope final : public ASTScopeImpl {
11301130
class DifferentiableAttributeScope final : public ASTScopeImpl {
11311131
public:
11321132
DifferentiableAttr *const differentiableAttr;
1133-
ValueDecl *const attributedDeclaration;
1133+
Decl *const attributedDeclaration;
11341134

1135-
DifferentiableAttributeScope(DifferentiableAttr *diffAttr, ValueDecl *decl)
1135+
DifferentiableAttributeScope(DifferentiableAttr *diffAttr, Decl *decl)
11361136
: differentiableAttr(diffAttr), attributedDeclaration(decl) {}
11371137
virtual ~DifferentiableAttributeScope() {}
11381138

lib/AST/ASTScopeCreation.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class ScopeCreator final : public ASTAllocated<ScopeCreator> {
180180
addChildrenForParsedAccessors(AbstractStorageDecl *asd,
181181
ASTScopeImpl *parent);
182182

183-
void addChildrenForKnownAttributes(ValueDecl *decl,
183+
void addChildrenForKnownAttributes(Decl *decl,
184184
ASTScopeImpl *parent);
185185

186186
/// Add PatternEntryDeclScopes for each pattern binding entry.
@@ -569,7 +569,7 @@ void ScopeCreator::addChildrenForParsedAccessors(
569569
});
570570
}
571571

572-
void ScopeCreator::addChildrenForKnownAttributes(ValueDecl *decl,
572+
void ScopeCreator::addChildrenForKnownAttributes(Decl *decl,
573573
ASTScopeImpl *parent) {
574574
SmallVector<DeclAttribute *, 2> relevantAttrs;
575575

@@ -601,10 +601,8 @@ void ScopeCreator::addChildrenForKnownAttributes(ValueDecl *decl,
601601
parent, specAttr, afd);
602602
}
603603
} else if (auto *customAttr = dyn_cast<CustomAttr>(attr)) {
604-
if (auto *vd = dyn_cast<VarDecl>(decl)) {
605-
constructExpandAndInsert<CustomAttributeScope>(
606-
parent, customAttr, vd);
607-
}
604+
constructExpandAndInsert<CustomAttributeScope>(
605+
parent, customAttr, decl);
608606
}
609607
}
610608
}
@@ -1192,7 +1190,9 @@ ASTScopeImpl *GenericTypeOrExtensionWholePortion::expandScope(
11921190
GenericTypeOrExtensionScope *scope, ScopeCreator &scopeCreator) const {
11931191
// Get now in case recursion emancipates scope
11941192
auto *const ip = scope->getParent().get();
1195-
1193+
1194+
scopeCreator.addChildrenForKnownAttributes(scope->getDecl(), scope);
1195+
11961196
auto *context = scope->getGenericContext();
11971197
auto *genericParams = (isa<TypeAliasDecl>(context)
11981198
? context->getParsedGenericParams()

0 commit comments

Comments
 (0)