@@ -1316,8 +1316,7 @@ bool Decl::hasUnderscoredNaming() const {
13161316 // underscore, it's a private function or subscript.
13171317 if (isa<AbstractFunctionDecl>(D) || isa<SubscriptDecl>(D)) {
13181318 const auto VD = cast<ValueDecl>(D);
1319- if (getParameterList (const_cast <ValueDecl *>(VD))
1320- ->hasInternalParameter (" _" )) {
1319+ if (VD->getParameterList ()->hasInternalParameter (" _" )) {
13211320 return true ;
13221321 }
13231322 }
@@ -4096,6 +4095,26 @@ ValueDecl::getCachedOpaqueResultTypeDecl() const {
40964095 .getCachedResult ();
40974096}
40984097
4098+ ParameterList *ValueDecl::getParameterList () {
4099+ if (auto *function = dyn_cast<AbstractFunctionDecl>(this )) {
4100+ return function->getParameters ();
4101+ } else if (auto *enumElement = dyn_cast<EnumElementDecl>(this )) {
4102+ return enumElement->getParameterList ();
4103+ } else if (auto *subscript = dyn_cast<SubscriptDecl>(this )) {
4104+ return subscript->getIndices ();
4105+ } else if (auto *macro = dyn_cast<MacroDecl>(this )) {
4106+ return macro->parameterList ;
4107+ }
4108+
4109+ return nullptr ;
4110+ }
4111+
4112+ const ParameterList *ValueDecl::getParameterList () const {
4113+ return const_cast <ValueDecl *>(this )->getParameterList ();
4114+ }
4115+
4116+ bool ValueDecl::hasParameterList () const { return (bool )getParameterList (); }
4117+
40994118bool ValueDecl::isObjC () const {
41004119 ASTContext &ctx = getASTContext ();
41014120 return evaluateOrDefault (ctx.evaluator ,
@@ -9578,24 +9597,10 @@ DeclName AbstractFunctionDecl::getEffectiveFullName() const {
95789597 return DeclName ();
95799598}
95809599
9581- ParameterList *swift::getParameterList (ValueDecl *source) {
9582- if (auto *AFD = dyn_cast<AbstractFunctionDecl>(source)) {
9583- return AFD->getParameters ();
9584- } else if (auto *EED = dyn_cast<EnumElementDecl>(source)) {
9585- return EED->getParameterList ();
9586- } else if (auto *SD = dyn_cast<SubscriptDecl>(source)) {
9587- return SD->getIndices ();
9588- } else if (auto *MD = dyn_cast<MacroDecl>(source)) {
9589- return MD->parameterList ;
9590- }
9591-
9592- return nullptr ;
9593- }
9594-
95959600ParameterList *swift::getParameterList (DeclContext *source) {
95969601 if (auto *D = source->getAsDecl ()) {
95979602 if (auto *VD = dyn_cast<ValueDecl>(D)) {
9598- return getParameterList (VD );
9603+ return VD-> getParameterList ();
95999604 }
96009605 } else if (auto *CE = dyn_cast<AbstractClosureExpr>(source)) {
96019606 return CE->getParameters ();
@@ -9607,7 +9612,7 @@ ParameterList *swift::getParameterList(DeclContext *source) {
96079612const ParamDecl *swift::getParameterAt (ConcreteDeclRef declRef,
96089613 unsigned index) {
96099614 auto *source = declRef.getDecl ();
9610- if (auto *params = getParameterList (const_cast <ValueDecl *>(source) )) {
9615+ if (auto *params = source-> getParameterList ()) {
96119616 unsigned origIndex = params->getOrigParamIndex (declRef.getSubstitutions (),
96129617 index);
96139618 return params->get (origIndex);
@@ -9617,7 +9622,7 @@ const ParamDecl *swift::getParameterAt(ConcreteDeclRef declRef,
96179622
96189623const ParamDecl *swift::getParameterAt (const ValueDecl *source,
96199624 unsigned index) {
9620- if (auto *params = getParameterList (const_cast <ValueDecl *>(source) )) {
9625+ if (auto *params = source-> getParameterList ()) {
96219626 return index < params->size () ? params->get (index) : nullptr ;
96229627 }
96239628 return nullptr ;
0 commit comments