Add support for class private methods (#703)
* Add support for class private methods This commit adds parser support for the TC39 Stage 2 Private Methods proposal. This commit also changes "key" in ClassPrivateProperty from an Identifier to a PrivateName, as well as disallowing #constructor as a valid private field name. * Add tests for string literal get/set/async These should be treated as regular methods and not special get/set/async behaviour. * Add tests for class private methods This also removes a test from the Test262 whitelist that failed before the changes for private methods support and now passes. * Modify class private prop tests for PrivateName * Add class private prop tests for #constructor * Fix existing ASI test case failure
This commit is contained in:
committed by
Justin Ridgewell
parent
b65b5a2f1c
commit
65bea96544
@@ -1526,7 +1526,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
}
|
||||
|
||||
// parse type parameters for class methods
|
||||
parseClassMethod(
|
||||
pushClassMethod(
|
||||
classBody: N.ClassBody,
|
||||
method: N.ClassMethod,
|
||||
isGenerator: boolean,
|
||||
@@ -1541,7 +1541,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
method.typeParameters = this.flowParseTypeParameterDeclaration();
|
||||
}
|
||||
|
||||
super.parseClassMethod(
|
||||
super.pushClassMethod(
|
||||
classBody,
|
||||
method,
|
||||
isGenerator,
|
||||
@@ -1550,6 +1550,23 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
);
|
||||
}
|
||||
|
||||
pushClassPrivateMethod(
|
||||
classBody: N.ClassBody,
|
||||
method: N.ClassPrivateMethod,
|
||||
isGenerator: boolean,
|
||||
isAsync: boolean,
|
||||
): void {
|
||||
if (method.variance) {
|
||||
this.unexpected(method.variance.start);
|
||||
}
|
||||
delete method.variance;
|
||||
if (this.isRelational("<")) {
|
||||
method.typeParameters = this.flowParseTypeParameterDeclaration();
|
||||
}
|
||||
|
||||
super.pushClassPrivateMethod(classBody, method, isGenerator, isAsync);
|
||||
}
|
||||
|
||||
// parse a the super class type parameters and implements
|
||||
parseClassSuper(node: N.Class): void {
|
||||
super.parseClassSuper(node);
|
||||
|
||||
Reference in New Issue
Block a user