diff --git a/lib/output.js b/lib/output.js index b57eb3a8..2f8faf7d 100644 --- a/lib/output.js +++ b/lib/output.js @@ -730,15 +730,9 @@ function OutputStream(options) { return p instanceof AST_PropAccess && p.expression === this; }); - PARENS(AST_ClassExpression, function(output){ - return output.parent() instanceof AST_SimpleStatement; - }); - // same goes for an object literal, because otherwise it would be // interpreted as a block of code. - PARENS(AST_Object, function(output){ - return first_in_statement(output); - }); + PARENS([ AST_ClassExpression, AST_Object ], first_in_statement); PARENS(AST_Unary, function(output){ var p = output.parent(); diff --git a/test/compress/harmony.js b/test/compress/harmony.js index fd0212dd..c094ff54 100644 --- a/test/compress/harmony.js +++ b/test/compress/harmony.js @@ -1197,3 +1197,18 @@ class_method_using_arguments: { expect_stdout: "PASS" node_version: ">=6" } + +issue_2676: { + options = { + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + class A {} + A.a = 42; + } + expect: { + (class {}).a = 42; + } +}