File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -7405,10 +7405,12 @@ inline EnumElementDecl *EnumDecl::getUniqueElement(bool hasValue) const {
7405
7405
return result;
7406
7406
}
7407
7407
7408
- // / Retrieve the parameter list for a given declaration.
7408
+ // / Retrieve the parameter list for a given declaration, or nullputr if there
7409
+ // / is none.
7409
7410
ParameterList *getParameterList (ValueDecl *source);
7410
7411
7411
- // / Retrieve parameter declaration from the given source at given index.
7412
+ // / Retrieve parameter declaration from the given source at given index, or
7413
+ // / nullptr if the source does not have a parameter list.
7412
7414
const ParamDecl *getParameterAt (const ValueDecl *source, unsigned index);
7413
7415
7414
7416
// / Display Decl subclasses.
Original file line number Diff line number Diff line change @@ -6623,14 +6623,19 @@ ParameterList *swift::getParameterList(ValueDecl *source) {
6623
6623
return AFD->getParameters ();
6624
6624
} else if (auto *EED = dyn_cast<EnumElementDecl>(source)) {
6625
6625
return EED->getParameterList ();
6626
- } else {
6627
- return cast<SubscriptDecl>(source) ->getIndices ();
6626
+ } else if ( auto *SD = dyn_cast<SubscriptDecl>(source)) {
6627
+ return SD ->getIndices ();
6628
6628
}
6629
+
6630
+ return nullptr ;
6629
6631
}
6630
6632
6631
6633
const ParamDecl *swift::getParameterAt (const ValueDecl *source,
6632
6634
unsigned index) {
6633
- return getParameterList (const_cast <ValueDecl *>(source))->get (index);
6635
+ if (auto *params = getParameterList (const_cast <ValueDecl *>(source))) {
6636
+ return params->get (index);
6637
+ }
6638
+ return nullptr ;
6634
6639
}
6635
6640
6636
6641
Type AbstractFunctionDecl::getMethodInterfaceType () const {
You can’t perform that action at this time.
0 commit comments