Skip to content

Commit 8fdb48d

Browse files
committed
[AST] Rename SubscriptDecl::create -> createParsed
And generate the DeclName using the argument labels on the ParameterList.
1 parent 9710a65 commit 8fdb48d

File tree

3 files changed

+18
-23
lines changed

3 files changed

+18
-23
lines changed

include/swift/AST/Decl.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6843,13 +6843,12 @@ class SubscriptDecl : public GenericContext, public AbstractStorageDecl {
68436843
Type ElementTy, DeclContext *Parent,
68446844
GenericParamList *GenericParams);
68456845

6846-
static SubscriptDecl *create(ASTContext &Context, DeclName Name,
6847-
SourceLoc StaticLoc,
6848-
StaticSpellingKind StaticSpelling,
6849-
SourceLoc SubscriptLoc, ParameterList *Indices,
6850-
SourceLoc ArrowLoc, TypeRepr *ElementTyR,
6851-
DeclContext *Parent,
6852-
GenericParamList *GenericParams);
6846+
static SubscriptDecl *createParsed(ASTContext &Context, SourceLoc StaticLoc,
6847+
StaticSpellingKind StaticSpelling,
6848+
SourceLoc SubscriptLoc,
6849+
ParameterList *Indices, SourceLoc ArrowLoc,
6850+
TypeRepr *ElementTyR, DeclContext *Parent,
6851+
GenericParamList *GenericParams);
68536852

68546853
static SubscriptDecl *create(ASTContext &Context, DeclName Name,
68556854
SourceLoc StaticLoc,

lib/AST/Decl.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8812,14 +8812,13 @@ SubscriptDecl::createDeserialized(ASTContext &Context, DeclName Name,
88128812
return SD;
88138813
}
88148814

8815-
SubscriptDecl *SubscriptDecl::create(ASTContext &Context, DeclName Name,
8816-
SourceLoc StaticLoc,
8817-
StaticSpellingKind StaticSpelling,
8818-
SourceLoc SubscriptLoc,
8819-
ParameterList *Indices, SourceLoc ArrowLoc,
8820-
TypeRepr *ElementTyR, DeclContext *Parent,
8821-
GenericParamList *GenericParams) {
8815+
SubscriptDecl *SubscriptDecl::createParsed(
8816+
ASTContext &Context, SourceLoc StaticLoc, StaticSpellingKind StaticSpelling,
8817+
SourceLoc SubscriptLoc, ParameterList *Indices, SourceLoc ArrowLoc,
8818+
TypeRepr *ElementTyR, DeclContext *Parent,
8819+
GenericParamList *GenericParams) {
88228820
assert(ElementTyR);
8821+
auto Name = DeclName(Context, DeclBaseName::createSubscript(), Indices);
88238822
auto *const SD = new (Context)
88248823
SubscriptDecl(Name, StaticLoc, StaticSpelling, SubscriptLoc, Indices,
88258824
ArrowLoc, ElementTyR, Parent, GenericParams);

lib/Parse/ParseDecl.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9508,10 +9508,9 @@ Parser::parseDeclSubscript(SourceLoc StaticLoc,
95089508

95099509
// Parse the parameter list.
95109510
DefaultArgumentInfo DefaultArgs;
9511-
SmallVector<Identifier, 4> argumentNames;
9512-
ParserResult<ParameterList> Indices
9513-
= parseSingleParameterClause(ParameterContextKind::Subscript,
9514-
&argumentNames, &DefaultArgs);
9511+
ParserResult<ParameterList> Indices =
9512+
parseSingleParameterClause(ParameterContextKind::Subscript,
9513+
/*argumentNamesOut*/ nullptr, &DefaultArgs);
95159514
Status |= Indices;
95169515
if (Status.hasCodeCompletion() && !CodeCompletionCallbacks)
95179516
return Status;
@@ -9554,11 +9553,9 @@ Parser::parseDeclSubscript(SourceLoc StaticLoc,
95549553
}
95559554

95569555
// Build an AST for the subscript declaration.
9557-
DeclName name = DeclName(Context, DeclBaseName::createSubscript(),
9558-
argumentNames);
9559-
auto *const Subscript = SubscriptDecl::create(
9560-
Context, name, StaticLoc, StaticSpelling, SubscriptLoc, Indices.get(),
9561-
ArrowLoc, ElementTy.get(), CurDeclContext, GenericParams);
9556+
auto *const Subscript = SubscriptDecl::createParsed(
9557+
Context, StaticLoc, StaticSpelling, SubscriptLoc, Indices.get(), ArrowLoc,
9558+
ElementTy.get(), CurDeclContext, GenericParams);
95629559
Subscript->getAttrs() = Attributes;
95639560

95649561
// Let the source file track the opaque return type mapping, if any.

0 commit comments

Comments
 (0)