better extends paren fix (#1962)

This commit is contained in:
kzc
2017-05-17 14:36:29 -04:00
committed by Alex Lam S.L
parent ebb469e4cd
commit b1b918e6d6
2 changed files with 50 additions and 9 deletions

View File

@@ -644,7 +644,6 @@ function OutputStream(options) {
* ==> 20 (side effect, set a := 10 and b := 20) */
|| p instanceof AST_Arrow // x => (x, x)
|| p instanceof AST_DefaultAssign // x => (x = (0, function(){}))
|| (p instanceof AST_Class && p.extends === this) // class D extends (calls++, C) {}
;
});
@@ -1474,8 +1473,12 @@ function OutputStream(options) {
output.space();
}
if (self.extends) {
var parens = self.extends instanceof AST_Binary ||
self.extends instanceof AST_Conditional;
var parens = (
!(self.extends instanceof AST_SymbolRef)
&& !(self.extends instanceof AST_PropAccess)
&& !(self.extends instanceof AST_ClassExpression)
&& !(self.extends instanceof AST_Function)
);
output.print("extends");
if (parens) {
output.print("(");