Skip to content

Commit 32ceba8

Browse files
committed
AST: Add GenericParamList::setDeclContext()
1 parent 8fcd74e commit 32ceba8

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

include/swift/AST/Decl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,6 +1309,8 @@ class GenericParamList final :
13091309
/// for more information.
13101310
void setOuterParameters(GenericParamList *Outer) { OuterParameters = Outer; }
13111311

1312+
void setDeclContext(DeclContext *dc);
1313+
13121314
SourceLoc getLAngleLoc() const { return Brackets.Start; }
13131315
SourceLoc getRAngleLoc() const { return Brackets.End; }
13141316

lib/AST/Decl.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,11 @@ void GenericParamList::setDepth(unsigned depth) {
964964
param->setDepth(depth);
965965
}
966966

967+
void GenericParamList::setDeclContext(DeclContext *dc) {
968+
for (auto param : *this)
969+
param->setDeclContext(dc);
970+
}
971+
967972
TrailingWhereClause::TrailingWhereClause(
968973
SourceLoc whereLoc,
969974
ArrayRef<RequirementRepr> requirements)

lib/AST/NameLookupRequests.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,9 @@ Optional<GenericParamList *> GenericParamListRequest::getCachedResult() const {
233233

234234
void GenericParamListRequest::cacheResult(GenericParamList *params) const {
235235
auto *context = std::get<0>(getStorage());
236-
if (params) {
237-
for (auto param : *params)
238-
param->setDeclContext(context);
239-
}
236+
if (params)
237+
params->setDeclContext(context);
238+
240239
context->GenericParamsAndBit.setPointerAndInt(params, true);
241240
}
242241

0 commit comments

Comments
 (0)