Also do the class extend parenthesis for class expressions (#403)

master
Christopher Chedeau 2017-01-22 15:35:45 -08:00 committed by GitHub
parent 4a47eff474
commit e45a9b0582
3 changed files with 7 additions and 1 deletions

View File

@ -195,7 +195,7 @@ FPp.needsParens = function(assumeExpressionContext) {
// Add parens around the extends clause of a class. It is needed for almost // Add parens around the extends clause of a class. It is needed for almost
// all expressions. // all expressions.
if ( if (
parent.type === "ClassDeclaration" && (parent.type === "ClassDeclaration" || parent.type === "ClassExpression") &&
parent.superClass === node && ( parent.superClass === node && (
node.type === "ArrowFunctionExpression" || node.type === "ArrowFunctionExpression" ||
node.type === "AssignmentExpression" || node.type === "AssignmentExpression" ||

View File

@ -54,6 +54,8 @@ function* f() {
// Flow has a bug parsing it. // Flow has a bug parsing it.
// class a extends (yield 1) {} // class a extends (yield 1) {}
} }
x = class extends (++b) {}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// \"ArrowFunctionExpression\" // \"ArrowFunctionExpression\"
class a extends (() => { class a extends (() => {
@ -112,5 +114,7 @@ function* f() {
// Flow has a bug parsing it. // Flow has a bug parsing it.
// class a extends (yield 1) {} // class a extends (yield 1) {}
} }
x = class extends (++b) {};
" "
`; `;

View File

@ -53,3 +53,5 @@ function* f() {
// Flow has a bug parsing it. // Flow has a bug parsing it.
// class a extends (yield 1) {} // class a extends (yield 1) {}
} }
x = class extends (++b) {}