@@ -1091,7 +1091,10 @@ static Token peekToken(Parser* parser)
1091
1091
return parser->tokenReader .peekToken ();
1092
1092
}
1093
1093
1094
- static SyntaxDecl* tryLookUpSyntaxDecl (Parser* parser, Name* name)
1094
+ static SyntaxDecl* tryLookUpSyntaxDecl (
1095
+ Parser* parser,
1096
+ Name* name,
1097
+ LookupMask syntaxLookupMask = LookupMask::Default)
1095
1098
{
1096
1099
// Let's look up the name and see what we find.
1097
1100
@@ -1100,7 +1103,7 @@ static SyntaxDecl* tryLookUpSyntaxDecl(Parser* parser, Name* name)
1100
1103
nullptr , // no semantics visitor available yet
1101
1104
name,
1102
1105
parser->currentScope ,
1103
- LookupMask::Default ,
1106
+ syntaxLookupMask ,
1104
1107
true );
1105
1108
1106
1109
// If we didn't find anything, or the result was overloaded,
@@ -1175,23 +1178,26 @@ bool tryParseUsingSyntaxDeclImpl(Parser* parser, SyntaxDecl* syntaxDecl, T** out
1175
1178
}
1176
1179
1177
1180
template <typename T>
1178
- bool tryParseUsingSyntaxDecl (Parser* parser, T** outSyntax)
1181
+ bool tryParseUsingSyntaxDecl (
1182
+ Parser* parser,
1183
+ T** outSyntax,
1184
+ LookupMask syntaxLookupMask = LookupMask::Default)
1179
1185
{
1180
1186
if (peekTokenType (parser) != TokenType::Identifier)
1181
1187
return false ;
1182
1188
1183
1189
auto nameToken = peekToken (parser);
1184
1190
auto name = nameToken.getName ();
1185
1191
1186
- auto syntaxDecl = tryLookUpSyntaxDecl (parser, name);
1192
+ auto syntaxDecl = tryLookUpSyntaxDecl (parser, name, syntaxLookupMask );
1187
1193
1188
1194
if (!syntaxDecl)
1189
1195
return false ;
1190
1196
1191
1197
return tryParseUsingSyntaxDeclImpl<T>(parser, syntaxDecl, outSyntax);
1192
1198
}
1193
1199
1194
- static Modifiers ParseModifiers (Parser* parser)
1200
+ static Modifiers ParseModifiers (Parser* parser, LookupMask modifierLookupMask = LookupMask::Default )
1195
1201
{
1196
1202
Modifiers modifiers;
1197
1203
Modifier** modifierLink = &modifiers.first ;
@@ -1212,7 +1218,7 @@ static Modifiers ParseModifiers(Parser* parser)
1212
1218
Token nameToken = peekToken (parser);
1213
1219
1214
1220
Modifier* parsedModifier = nullptr ;
1215
- if (tryParseUsingSyntaxDecl<Modifier>(parser, &parsedModifier))
1221
+ if (tryParseUsingSyntaxDecl<Modifier>(parser, &parsedModifier, modifierLookupMask ))
1216
1222
{
1217
1223
parsedModifier->keywordName = nameToken.getName ();
1218
1224
if (!parsedModifier->loc .isValid ())
@@ -4253,7 +4259,7 @@ static ParamDecl* parseModernParamDecl(Parser* parser)
4253
4259
// like `in`, `out`, and `in out`/`inout` be applied to the
4254
4260
// type (after the colon).
4255
4261
//
4256
- auto modifiers = ParseModifiers (parser);
4262
+ auto modifiers = ParseModifiers (parser, LookupMask::SyntaxDecl );
4257
4263
4258
4264
// We want to allow both "modern"-style and traditional-style
4259
4265
// parameters to appear in any modern-style parameter list,
@@ -4918,7 +4924,7 @@ static DeclBase* ParseDeclWithModifiers(
4918
4924
// as a declaration keyword and parse a declaration using
4919
4925
// its associated callback:
4920
4926
Decl* parsedDecl = nullptr ;
4921
- if (tryParseUsingSyntaxDecl<Decl>(parser, &parsedDecl))
4927
+ if (tryParseUsingSyntaxDecl<Decl>(parser, &parsedDecl, LookupMask::Default ))
4922
4928
{
4923
4929
decl = parsedDecl;
4924
4930
break ;
@@ -6293,7 +6299,7 @@ ExpressionStmt* Parser::ParseExpressionStatement()
6293
6299
ParamDecl* Parser::ParseParameter ()
6294
6300
{
6295
6301
ParamDecl* parameter = astBuilder->create <ParamDecl>();
6296
- parameter->modifiers = ParseModifiers (this );
6302
+ parameter->modifiers = ParseModifiers (this , LookupMask::SyntaxDecl );
6297
6303
currentLookupScope = currentScope->parent ;
6298
6304
_parseTraditionalParamDeclCommonBase (this , parameter, kDeclaratorParseOption_AllowEmpty );
6299
6305
resetLookupScope ();
0 commit comments