Skip to content

Commit 82eae19

Browse files
committed
Inlined checks for NodeFlags.Async in parser
1 parent b25d855 commit 82eae19

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/compiler/parser.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2695,13 +2695,15 @@ namespace ts {
26952695
// Didn't appear to actually be a parenthesized arrow function. Just bail out.
26962696
return undefined;
26972697
}
2698+
2699+
let isAsync = !!(arrowFunction.flags & NodeFlags.Async);
26982700

26992701
// If we have an arrow, then try to parse the body. Even if not, try to parse if we
27002702
// have an opening brace, just in case we're in an error state.
27012703
var lastToken = token;
27022704
arrowFunction.equalsGreaterThanToken = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken, /*reportAtCurrentPosition*/false, Diagnostics._0_expected, "=>");
27032705
arrowFunction.body = (lastToken === SyntaxKind.EqualsGreaterThanToken || lastToken === SyntaxKind.OpenBraceToken)
2704-
? parseArrowFunctionExpressionBody(/*isAsync*/ isAsyncFunctionLike(arrowFunction))
2706+
? parseArrowFunctionExpressionBody(isAsync)
27052707
: parseIdentifier();
27062708

27072709
return finishNode(arrowFunction);
@@ -2813,7 +2815,7 @@ namespace ts {
28132815
function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity: boolean): ArrowFunction {
28142816
let node = <ArrowFunction>createNode(SyntaxKind.ArrowFunction);
28152817
setModifiers(node, parseModifiersForArrowFunction());
2816-
let isAsync = isAsyncFunctionLike(node);
2818+
let isAsync = !!(node.flags & NodeFlags.Async);
28172819

28182820
// Arrow functions are never generators.
28192821
//
@@ -3493,7 +3495,7 @@ namespace ts {
34933495
node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken);
34943496

34953497
let isGenerator = !!node.asteriskToken;
3496-
let isAsync = isAsyncFunctionLike(node);
3498+
let isAsync = !!(node.flags & NodeFlags.Async);
34973499
node.name =
34983500
isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) :
34993501
isGenerator ? doInYieldContext(parseOptionalIdentifier) :
@@ -4217,7 +4219,7 @@ namespace ts {
42174219
node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken);
42184220
node.name = node.flags & NodeFlags.Default ? parseOptionalIdentifier() : parseIdentifier();
42194221
let isGenerator = !!node.asteriskToken;
4220-
let isAsync = isAsyncFunctionLike(node);
4222+
let isAsync = !!(node.flags & NodeFlags.Async);
42214223
fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node);
42224224
node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, Diagnostics.or_expected);
42234225
return finishNode(node);
@@ -4241,7 +4243,7 @@ namespace ts {
42414243
method.name = name;
42424244
method.questionToken = questionToken;
42434245
let isGenerator = !!asteriskToken;
4244-
let isAsync = isAsyncFunctionLike(method);
4246+
let isAsync = !!(method.flags & NodeFlags.Async);
42454247
fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method);
42464248
method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage);
42474249
return finishNode(method);

0 commit comments

Comments
 (0)