@@ -1337,8 +1337,7 @@ bool Decl::hasUnderscoredNaming() const {
13371337 // underscore, it's a private function or subscript.
13381338 if (isa<AbstractFunctionDecl>(D) || isa<SubscriptDecl>(D)) {
13391339 const auto VD = cast<ValueDecl>(D);
1340- if (getParameterList (const_cast <ValueDecl *>(VD))
1341- ->hasInternalParameter (" _" )) {
1340+ if (VD->getParameterList ()->hasInternalParameter (" _" )) {
13421341 return true ;
13431342 }
13441343 }
@@ -4117,6 +4116,26 @@ ValueDecl::getCachedOpaqueResultTypeDecl() const {
41174116 .getCachedResult ();
41184117}
41194118
4119+ ParameterList *ValueDecl::getParameterList () {
4120+ if (auto *function = dyn_cast<AbstractFunctionDecl>(this )) {
4121+ return function->getParameters ();
4122+ } else if (auto *enumElement = dyn_cast<EnumElementDecl>(this )) {
4123+ return enumElement->getParameterList ();
4124+ } else if (auto *subscript = dyn_cast<SubscriptDecl>(this )) {
4125+ return subscript->getIndices ();
4126+ } else if (auto *macro = dyn_cast<MacroDecl>(this )) {
4127+ return macro->parameterList ;
4128+ }
4129+
4130+ return nullptr ;
4131+ }
4132+
4133+ const ParameterList *ValueDecl::getParameterList () const {
4134+ return const_cast <ValueDecl *>(this )->getParameterList ();
4135+ }
4136+
4137+ bool ValueDecl::hasParameterList () const { return (bool )getParameterList (); }
4138+
41204139bool ValueDecl::isObjC () const {
41214140 ASTContext &ctx = getASTContext ();
41224141 return evaluateOrDefault (ctx.evaluator ,
@@ -4182,6 +4201,24 @@ bool ValueDecl::isDynamic() const {
41824201 getAttrs ().hasAttribute <DynamicAttr>());
41834202}
41844203
4204+ bool ValueDecl::isAsync () const {
4205+ if (auto *function = dyn_cast<AbstractFunctionDecl>(this )) {
4206+ return function->hasAsync ();
4207+ }
4208+
4209+ // Async storage declarations must be get-only. Don't consider it async
4210+ // otherwise, even if it has an async getter.
4211+ if (auto *storage = dyn_cast<AbstractStorageDecl>(this )) {
4212+ if (storage->getAllAccessors ().size () == 1 ) {
4213+ if (auto *getter = storage->getAccessor (AccessorKind::Get)) {
4214+ return getter->hasAsync ();
4215+ }
4216+ }
4217+ }
4218+
4219+ return false ;
4220+ }
4221+
41854222bool ValueDecl::isObjCDynamicInGenericClass () const {
41864223 if (!isObjCDynamic ())
41874224 return false ;
@@ -9599,24 +9636,10 @@ DeclName AbstractFunctionDecl::getEffectiveFullName() const {
95999636 return DeclName ();
96009637}
96019638
9602- ParameterList *swift::getParameterList (ValueDecl *source) {
9603- if (auto *AFD = dyn_cast<AbstractFunctionDecl>(source)) {
9604- return AFD->getParameters ();
9605- } else if (auto *EED = dyn_cast<EnumElementDecl>(source)) {
9606- return EED->getParameterList ();
9607- } else if (auto *SD = dyn_cast<SubscriptDecl>(source)) {
9608- return SD->getIndices ();
9609- } else if (auto *MD = dyn_cast<MacroDecl>(source)) {
9610- return MD->parameterList ;
9611- }
9612-
9613- return nullptr ;
9614- }
9615-
96169639ParameterList *swift::getParameterList (DeclContext *source) {
96179640 if (auto *D = source->getAsDecl ()) {
96189641 if (auto *VD = dyn_cast<ValueDecl>(D)) {
9619- return getParameterList (VD );
9642+ return VD-> getParameterList ();
96209643 }
96219644 } else if (auto *CE = dyn_cast<AbstractClosureExpr>(source)) {
96229645 return CE->getParameters ();
@@ -9628,7 +9651,7 @@ ParameterList *swift::getParameterList(DeclContext *source) {
96289651const ParamDecl *swift::getParameterAt (ConcreteDeclRef declRef,
96299652 unsigned index) {
96309653 auto *source = declRef.getDecl ();
9631- if (auto *params = getParameterList (const_cast <ValueDecl *>(source) )) {
9654+ if (auto *params = source-> getParameterList ()) {
96329655 unsigned origIndex = params->getOrigParamIndex (declRef.getSubstitutions (),
96339656 index);
96349657 return params->get (origIndex);
@@ -9638,7 +9661,7 @@ const ParamDecl *swift::getParameterAt(ConcreteDeclRef declRef,
96389661
96399662const ParamDecl *swift::getParameterAt (const ValueDecl *source,
96409663 unsigned index) {
9641- if (auto *params = getParameterList (const_cast <ValueDecl *>(source) )) {
9664+ if (auto *params = source-> getParameterList ()) {
96429665 return index < params->size () ? params->get (index) : nullptr ;
96439666 }
96449667 return nullptr ;
0 commit comments