Remove always false param allowExpressionBody (#9591)

This commit is contained in:
Daniel Tschinder 2019-02-26 11:15:34 -08:00 committed by GitHub
parent e1ff4c47b9
commit 244e4580e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 15 deletions

View File

@ -881,7 +881,7 @@ export default class ExpressionParser extends LValParser {
!this.canInsertSemicolon() !this.canInsertSemicolon()
) { ) {
this.next(); this.next();
return this.parseFunction(node, undefined, false, true); return this.parseFunction(node, undefined, true);
} else if ( } else if (
canBeArrow && canBeArrow &&
id.name === "async" && id.name === "async" &&
@ -1804,10 +1804,9 @@ export default class ExpressionParser extends LValParser {
parseFunctionBodyAndFinish( parseFunctionBodyAndFinish(
node: N.BodilessFunctionOrMethodBase, node: N.BodilessFunctionOrMethodBase,
type: string, type: string,
allowExpressionBody?: boolean,
): void { ): void {
// $FlowIgnore (node is not bodiless if we get here) // $FlowIgnore (node is not bodiless if we get here)
this.parseFunctionBody(node, allowExpressionBody); this.parseFunctionBody(node);
this.finishNode(node, type); this.finishNode(node, type);
} }

View File

@ -548,7 +548,6 @@ export default class StatementParser extends ExpressionParser {
return this.parseFunction( return this.parseFunction(
node, node,
FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT),
false,
isAsync, isAsync,
); );
} }
@ -1013,7 +1012,6 @@ export default class StatementParser extends ExpressionParser {
parseFunction<T: N.NormalFunction>( parseFunction<T: N.NormalFunction>(
node: T, node: T,
statement?: number = FUNC_NO_FLAGS, statement?: number = FUNC_NO_FLAGS,
allowExpressionBody?: boolean = false,
isAsync?: boolean = false, isAsync?: boolean = false,
): T { ): T {
const isStatement = statement & FUNC_STATEMENT; const isStatement = statement & FUNC_STATEMENT;
@ -1074,7 +1072,6 @@ export default class StatementParser extends ExpressionParser {
this.parseFunctionBodyAndFinish( this.parseFunctionBodyAndFinish(
node, node,
isStatement ? "FunctionDeclaration" : "FunctionExpression", isStatement ? "FunctionDeclaration" : "FunctionExpression",
allowExpressionBody,
); );
}); });
@ -1753,7 +1750,6 @@ export default class StatementParser extends ExpressionParser {
return this.parseFunction( return this.parseFunction(
expr, expr,
FUNC_STATEMENT | FUNC_NULLABLE_ID, FUNC_STATEMENT | FUNC_NULLABLE_ID,
false,
isAsync, isAsync,
); );
} else if (this.match(tt._class)) { } else if (this.match(tt._class)) {

View File

@ -1557,10 +1557,8 @@ export default (superClass: Class<Parser>): Class<Parser> =>
parseFunctionBodyAndFinish( parseFunctionBodyAndFinish(
node: N.BodilessFunctionOrMethodBase, node: N.BodilessFunctionOrMethodBase,
type: string, type: string,
allowExpressionBody?: boolean,
): void { ): void {
// For arrow functions, `parseArrow` handles the return type itself. if (this.match(tt.colon)) {
if (!allowExpressionBody && this.match(tt.colon)) {
const typeNode = this.startNode(); const typeNode = this.startNode();
[ [
@ -1575,7 +1573,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
: null; : null;
} }
super.parseFunctionBodyAndFinish(node, type, allowExpressionBody); super.parseFunctionBodyAndFinish(node, type);
} }
// interfaces // interfaces

View File

@ -1481,10 +1481,8 @@ export default (superClass: Class<Parser>): Class<Parser> =>
parseFunctionBodyAndFinish( parseFunctionBodyAndFinish(
node: N.BodilessFunctionOrMethodBase, node: N.BodilessFunctionOrMethodBase,
type: string, type: string,
allowExpressionBody?: boolean,
): void { ): void {
// For arrow functions, `parseArrow` handles the return type itself. if (this.match(tt.colon)) {
if (!allowExpressionBody && this.match(tt.colon)) {
node.returnType = this.tsParseTypeOrTypePredicateAnnotation(tt.colon); node.returnType = this.tsParseTypeOrTypePredicateAnnotation(tt.colon);
} }
@ -1499,7 +1497,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
return; return;
} }
super.parseFunctionBodyAndFinish(node, type, allowExpressionBody); super.parseFunctionBodyAndFinish(node, type);
} }
parseSubscript( parseSubscript(