Skip to content

Commit 487d3b4

Browse files
committed
[NFC] Simplify some code using ValueDecl::getParameterList
1 parent 182bfc6 commit 487d3b4

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

lib/AST/NameLookup.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3710,13 +3710,14 @@ createOpaqueParameterGenericParams(GenericContext *genericContext, GenericParamL
37103710
return { };
37113711

37123712
// Functions, initializers, and subscripts can contain opaque parameters.
3713-
ParameterList *params = nullptr;
3714-
if (auto func = dyn_cast<AbstractFunctionDecl>(value))
3715-
params = func->getParameters();
3716-
else if (auto subscript = dyn_cast<SubscriptDecl>(value))
3717-
params = subscript->getIndices();
3718-
else
3713+
// FIXME: What's wrong with allowing them in macro decls?
3714+
if (isa<MacroDecl>(value)) {
37193715
return { };
3716+
}
3717+
auto *params = value->getParameterList();
3718+
if (!params) {
3719+
return {};
3720+
}
37203721

37213722
// Look for parameters that have "some" types in them.
37223723
unsigned index = parsedGenericParams ? parsedGenericParams->size() : 0;

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7262,7 +7262,7 @@ static AnyFunctionType *applyUnsafeConcurrencyToFunctionType(
72627262

72637263
SmallVector<AnyFunctionType::Param, 4> newTypeParams;
72647264
auto typeParams = fnType->getParams();
7265-
auto paramDecls = func ? func->getParameters() : subscript->getIndices();
7265+
auto paramDecls = decl->getParameterList();
72667266
assert(typeParams.size() == paramDecls->size());
72677267
bool knownUnsafeParams = func && hasKnownUnsafeSendableFunctionParams(func);
72687268
bool stripConcurrency =

lib/Sema/TypeCheckGeneric.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -714,10 +714,8 @@ GenericSignatureRequest::evaluate(Evaluator &evaluator,
714714
/*unboundTyOpener*/ nullptr,
715715
/*placeholderHandler*/ nullptr,
716716
/*packElementOpener*/ nullptr);
717-
auto params = func ? func->getParameters()
718-
: subscr ? subscr->getIndices()
719-
: macro->parameterList;
720-
for (auto param : *params) {
717+
718+
for (auto param : *VD->getParameterList()) {
721719
auto *typeRepr = param->getTypeRepr();
722720
if (typeRepr == nullptr)
723721
continue;

0 commit comments

Comments
 (0)