@@ -8888,6 +8888,21 @@ ParamDecl *ParamDecl::clone(const ASTContext &Ctx, ParamDecl *PD) {
8888
8888
return Clone;
8889
8889
}
8890
8890
8891
+ ParamDecl *ParamDecl::cloneAccessor (const ASTContext &Ctx,
8892
+ ParamDecl const *subscriptParam,
8893
+ DeclContext *Parent) {
8894
+ auto *param = new (Ctx) ParamDecl (
8895
+ subscriptParam->getSpecifierLoc (), subscriptParam->getArgumentNameLoc (),
8896
+ subscriptParam->getArgumentName (), subscriptParam->getNameLoc (),
8897
+ subscriptParam->getName (), /* declContext*/ Parent);
8898
+ param->setOptions (subscriptParam->getOptions ());
8899
+
8900
+ // The cloned parameter is implicit.
8901
+ param->setImplicit ();
8902
+
8903
+ return param;
8904
+ }
8905
+
8891
8906
ParamDecl *
8892
8907
ParamDecl::createImplicit (ASTContext &Context, SourceLoc specifierLoc,
8893
8908
SourceLoc argumentNameLoc, Identifier argumentName,
@@ -11107,23 +11122,7 @@ AccessorDecl *AccessorDecl::createParsed(
11107
11122
paramsEnd = indices->getEndLoc ();
11108
11123
}
11109
11124
for (auto *subscriptParam : *indices) {
11110
- // Clone the parameter.
11111
- auto *param = new (ctx) ParamDecl (
11112
- subscriptParam->getSpecifierLoc (),
11113
- subscriptParam->getArgumentNameLoc (),
11114
- subscriptParam->getArgumentName (), subscriptParam->getNameLoc (),
11115
- subscriptParam->getName (), /* declContext*/ accessor);
11116
-
11117
- // The cloned parameter is implicit.
11118
- param->setImplicit ();
11119
-
11120
- // TODO: Check why IsVariadic is not copied.
11121
- param->setAutoClosure (subscriptParam->isAutoClosure ());
11122
- param->setIsolated (subscriptParam->isIsolated ());
11123
- // TODO: Check why IsAddressable is not copied.
11124
- param->setSending (subscriptParam->isSending ());
11125
- param->setCallerIsolated (subscriptParam->isCallerIsolated ());
11126
-
11125
+ auto param = ParamDecl::cloneAccessor (ctx, subscriptParam, accessor);
11127
11126
newParams.push_back (param);
11128
11127
}
11129
11128
0 commit comments