@@ -8918,6 +8918,21 @@ ParamDecl *ParamDecl::clone(const ASTContext &Ctx, ParamDecl *PD) {
8918
8918
return Clone;
8919
8919
}
8920
8920
8921
+ ParamDecl *ParamDecl::cloneAccessor (const ASTContext &Ctx,
8922
+ ParamDecl const *subscriptParam,
8923
+ DeclContext *Parent) {
8924
+ auto *param = new (Ctx) ParamDecl (
8925
+ subscriptParam->getSpecifierLoc (), subscriptParam->getArgumentNameLoc (),
8926
+ subscriptParam->getArgumentName (), subscriptParam->getNameLoc (),
8927
+ subscriptParam->getName (), /* declContext*/ Parent);
8928
+ param->setOptions (subscriptParam->getOptions ());
8929
+
8930
+ // The cloned parameter is implicit.
8931
+ param->setImplicit ();
8932
+
8933
+ return param;
8934
+ }
8935
+
8921
8936
ParamDecl *
8922
8937
ParamDecl::createImplicit (ASTContext &Context, SourceLoc specifierLoc,
8923
8938
SourceLoc argumentNameLoc, Identifier argumentName,
@@ -11128,23 +11143,7 @@ AccessorDecl *AccessorDecl::createParsed(
11128
11143
paramsEnd = indices->getEndLoc ();
11129
11144
}
11130
11145
for (auto *subscriptParam : *indices) {
11131
- // Clone the parameter.
11132
- auto *param = new (ctx) ParamDecl (
11133
- subscriptParam->getSpecifierLoc (),
11134
- subscriptParam->getArgumentNameLoc (),
11135
- subscriptParam->getArgumentName (), subscriptParam->getNameLoc (),
11136
- subscriptParam->getName (), /* declContext*/ accessor);
11137
-
11138
- // The cloned parameter is implicit.
11139
- param->setImplicit ();
11140
-
11141
- // TODO: Check why IsVariadic is not copied.
11142
- param->setAutoClosure (subscriptParam->isAutoClosure ());
11143
- param->setIsolated (subscriptParam->isIsolated ());
11144
- // TODO: Check why IsAddressable is not copied.
11145
- param->setSending (subscriptParam->isSending ());
11146
- param->setCallerIsolated (subscriptParam->isCallerIsolated ());
11147
-
11146
+ auto param = ParamDecl::cloneAccessor (ctx, subscriptParam, accessor);
11148
11147
newParams.push_back (param);
11149
11148
}
11150
11149
0 commit comments