| Index: runtime/vm/parser.cc
|
| diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
|
| index e2100454593513ff88c3821fd0702b90c74342f6..43d909f4e3af2f0b7a8f627314052ef065da7f46 100644
|
| --- a/runtime/vm/parser.cc
|
| +++ b/runtime/vm/parser.cc
|
| @@ -286,6 +286,7 @@ Parser::Parser(const Script& script, const Library& library, intptr_t token_pos)
|
| token_kind_(Token::kILLEGAL),
|
| current_block_(NULL),
|
| is_top_level_(false),
|
| + await_is_keyword_(false),
|
| current_member_(NULL),
|
| allow_function_literals_(true),
|
| parsed_function_(NULL),
|
| @@ -312,6 +313,7 @@ Parser::Parser(const Script& script,
|
| token_kind_(Token::kILLEGAL),
|
| current_block_(NULL),
|
| is_top_level_(false),
|
| + await_is_keyword_(false),
|
| current_member_(NULL),
|
| allow_function_literals_(true),
|
| parsed_function_(parsed_function),
|
| @@ -3053,6 +3055,11 @@ SequenceNode* Parser::ParseFunc(const Function& func,
|
| OpenAsyncClosure();
|
| }
|
|
|
| + bool saved_await_is_keyword = await_is_keyword_;
|
| + if (func.IsAsyncFunction() || func.is_async_closure()) {
|
| + await_is_keyword_ = true;
|
| + }
|
| +
|
| intptr_t end_token_pos = 0;
|
| if (CurrentToken() == Token::kLBRACE) {
|
| ConsumeToken();
|
| @@ -3121,6 +3128,7 @@ SequenceNode* Parser::ParseFunc(const Function& func,
|
| current_block_->statements->Add(body);
|
| innermost_function_ = saved_innermost_function.raw();
|
| last_used_try_index_ = saved_try_index;
|
| + await_is_keyword_ = saved_await_is_keyword;
|
| return CloseBlock();
|
| }
|
|
|
| @@ -6353,7 +6361,7 @@ bool Parser::IsSimpleLiteral(const AbstractType& type, Instance* value) {
|
|
|
| // Returns true if the current token is kIDENT or a pseudo-keyword.
|
| bool Parser::IsIdentifier() {
|
| - return Token::IsIdentifier(CurrentToken());
|
| + return Token::IsIdentifier(CurrentToken()) && !IsAwaitAsKeyword();
|
| }
|
|
|
|
|
| @@ -8002,6 +8010,12 @@ bool Parser::IsLiteral(const char* literal) {
|
| }
|
|
|
|
|
| +bool Parser::IsAwaitAsKeyword() {
|
| + return await_is_keyword_ &&
|
| + (CurrentLiteral()->raw() == Symbols::Await().raw());
|
| +}
|
| +
|
| +
|
| static bool IsIncrementOperator(Token::Kind token) {
|
| return token == Token::kINCR || token == Token::kDECR;
|
| }
|
| @@ -10939,9 +10953,7 @@ AstNode* Parser::ParsePrimary() {
|
| OpenBlock();
|
| primary = ParseFunctionStatement(true);
|
| CloseBlock();
|
| - } else if (IsLiteral("await") &&
|
| - (parsed_function()->function().IsAsyncFunction() ||
|
| - parsed_function()->function().is_async_closure())) {
|
| + } else if (IsAwaitAsKeyword()) {
|
| // The body of an async function is parsed multiple times. The first time
|
| // when setting up an AsyncFunction() for generating relevant scope
|
| // information. The second time the body is parsed for actually generating
|
|
|