Skip to content

Commit 4d216c7

Browse files
committed
[AST] Add swift::getParameterList
1 parent 7ddface commit 4d216c7

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

include/swift/AST/Decl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7286,6 +7286,9 @@ inline EnumElementDecl *EnumDecl::getUniqueElement(bool hasValue) const {
72867286
return result;
72877287
}
72887288

7289+
/// Retrieve the parameter list for a given declaration.
7290+
ParameterList *getParameterList(ValueDecl *source);
7291+
72897292
/// Retrieve parameter declaration from the given source at given index.
72907293
const ParamDecl *getParameterAt(const ValueDecl *source, unsigned index);
72917294

lib/AST/Decl.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6465,17 +6465,19 @@ DeclName AbstractFunctionDecl::getEffectiveFullName() const {
64656465
return DeclName();
64666466
}
64676467

6468-
const ParamDecl *swift::getParameterAt(const ValueDecl *source, unsigned index) {
6469-
const ParameterList *paramList;
6468+
ParameterList *swift::getParameterList(ValueDecl *source) {
64706469
if (auto *AFD = dyn_cast<AbstractFunctionDecl>(source)) {
6471-
paramList = AFD->getParameters();
6470+
return AFD->getParameters();
64726471
} else if (auto *EED = dyn_cast<EnumElementDecl>(source)) {
6473-
paramList = EED->getParameterList();
6472+
return EED->getParameterList();
64746473
} else {
6475-
paramList = cast<SubscriptDecl>(source)->getIndices();
6474+
return cast<SubscriptDecl>(source)->getIndices();
64766475
}
6476+
}
64776477

6478-
return paramList->get(index);
6478+
const ParamDecl *swift::getParameterAt(const ValueDecl *source,
6479+
unsigned index) {
6480+
return getParameterList(const_cast<ValueDecl *>(source))->get(index);
64796481
}
64806482

64816483
Type AbstractFunctionDecl::getMethodInterfaceType() const {

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -253,14 +253,6 @@ static bool checkObjCWitnessSelector(ValueDecl *req, ValueDecl *witness) {
253253
return false;
254254
}
255255

256-
static ParameterList *getParameterList(ValueDecl *value) {
257-
if (auto func = dyn_cast<AbstractFunctionDecl>(value))
258-
return func->getParameters();
259-
260-
auto subscript = cast<SubscriptDecl>(value);
261-
return subscript->getIndices();
262-
}
263-
264256
// Find a standin declaration to place the diagnostic at for the
265257
// given accessor kind.
266258
static ValueDecl *getStandinForAccessor(AbstractStorageDecl *witness,

0 commit comments

Comments
 (0)