Skip to content

Commit 2cfe8ad

Browse files
committed
Addressing feedback on how parseDefaultArgument should consume '=' or '=='
1 parent d82dd84 commit 2cfe8ad

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/Parse/ParsePattern.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,12 @@ void Parser::DefaultArgumentInfo::setFunctionContext(
6767
static ParserStatus parseDefaultArgument(
6868
Parser &P, Parser::DefaultArgumentInfo *defaultArgs, unsigned argIndex,
6969
Expr *&init, bool &hasInheritedDefaultArg,
70-
Parser::ParameterContextKind paramContext, tok assignmentTok) {
70+
Parser::ParameterContextKind paramContext) {
7171
SyntaxParsingContext DefaultArgContext(P.SyntaxContext,
7272
SyntaxKind::InitializerClause);
73-
SourceLoc equalLoc = P.consumeToken(assignmentTok);
73+
assert(P.Tok.is(tok::equal) ||
74+
(P.Tok.isBinaryOperator() && P.Tok.getText() == "=="));
75+
SourceLoc equalLoc = P.consumeToken();
7476

7577
if (P.SF.Kind == SourceFileKind::Interface) {
7678
// Swift module interfaces don't synthesize inherited intializers and
@@ -394,7 +396,7 @@ Parser::parseParameterClause(SourceLoc &leftParenLoc,
394396

395397
status |= parseDefaultArgument(
396398
*this, defaultArgs, defaultArgIndex, param.DefaultArg,
397-
param.hasInheritedDefaultArg, paramContext, Tok.getKind());
399+
param.hasInheritedDefaultArg, paramContext);
398400

399401
if (param.EllipsisLoc.isValid() && param.DefaultArg) {
400402
// The range of the complete default argument.

0 commit comments

Comments
 (0)