Skip to content

Commit b4962e1

Browse files
committed
Sema: Remove setAccess() call from prepareGenericParamList()
1 parent 6871d41 commit b4962e1

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

lib/AST/AccessRequests.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ AccessLevelRequest::evaluate(Evaluator &evaluator, ValueDecl *D) const {
6363
}
6464
}
6565

66+
DeclContext *DC = D->getDeclContext();
67+
68+
// Special case for generic parameters; we just give them a dummy
69+
// access level.
70+
if (auto genericParam = dyn_cast<GenericTypeParamDecl>(D)) {
71+
return AccessLevel::Internal;
72+
}
73+
6674
// Special case for associated types: inherit access from protocol.
6775
if (auto assocType = dyn_cast<AssociatedTypeDecl>(D)) {
6876
auto prot = assocType->getProtocol();
@@ -80,7 +88,6 @@ AccessLevelRequest::evaluate(Evaluator &evaluator, ValueDecl *D) const {
8088
}
8189
}
8290

83-
DeclContext *DC = D->getDeclContext();
8491
switch (DC->getContextKind()) {
8592
case DeclContextKind::TopLevelCodeDecl:
8693
// Variables declared in a top-level 'guard' statement can be accessed in

lib/Sema/TypeCheckGeneric.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -132,21 +132,10 @@ TypeChecker::gatherGenericParamBindingsText(
132132
void
133133
TypeChecker::prepareGenericParamList(GenericParamList *gp,
134134
DeclContext *dc) {
135-
AccessLevel access;
136-
if (auto *fd = dyn_cast<FuncDecl>(dc))
137-
access = fd->getFormalAccess();
138-
else if (auto *nominal = dyn_cast<NominalTypeDecl>(dc))
139-
access = nominal->getFormalAccess();
140-
else
141-
access = AccessLevel::Internal;
142-
access = std::max(access, AccessLevel::Internal);
143-
144135
unsigned depth = gp->getDepth();
145136
for (auto paramDecl : *gp) {
146137
checkDeclAttributesEarly(paramDecl);
147138
paramDecl->setDepth(depth);
148-
if (!paramDecl->hasAccess())
149-
paramDecl->setAccess(access);
150139
}
151140
}
152141

0 commit comments

Comments
 (0)