[parser] Parse only modifiers of actual methods (#10594)

* Parse only modifiers of actual methods

* Throw question token if is used before the real name
This commit is contained in:
gr
2019-10-29 13:56:05 -03:00
committed by Nicolò Ribaudo
parent 01927babe2
commit b6ef9689b2
5 changed files with 237 additions and 0 deletions

View File

@@ -1348,6 +1348,7 @@ export default class StatementParser extends ExpressionParser {
const isPrivate = key.type === "PrivateName";
// Check the key is not a computed expression or string literal.
const isSimple = key.type === "Identifier";
const maybeQuestionTokenStart = this.state.start;
this.parsePostMemberNameModifiers(publicMember);
@@ -1403,6 +1404,10 @@ export default class StatementParser extends ExpressionParser {
// an async method
const isGenerator = this.eat(tt.star);
if (publicMember.optional) {
this.unexpected(maybeQuestionTokenStart);
}
method.kind = "method";
// The so-called parsed name would have been "async": get the real name.
this.parseClassPropertyName(method);