deduplicate AST_Super & AST_This logic (#2366)

This commit is contained in:
Alex Lam S.L
2017-10-17 04:19:53 +08:00
committed by GitHub
parent a89f126db6
commit b6a7ca292e
4 changed files with 30 additions and 8 deletions

View File

@@ -1042,7 +1042,7 @@ var AST_This = DEFNODE("This", null, {
var AST_Super = DEFNODE("Super", null, {
$documentation: "The `super` symbol",
}, AST_Symbol);
}, AST_This);
var AST_Constant = DEFNODE("Constant", null, {
$documentation: "Base class for all constants",

View File

@@ -610,7 +610,6 @@ merge(Compressor.prototype, {
}
function is_lhs_read_only(lhs) {
if (lhs instanceof AST_Super) return true;
if (lhs instanceof AST_This) return true;
if (lhs instanceof AST_SymbolRef) return lhs.definition().orig[0] instanceof AST_SymbolLambda;
if (lhs instanceof AST_PropAccess) {
@@ -2143,7 +2142,6 @@ merge(Compressor.prototype, {
def(AST_EmptyStatement, return_false);
def(AST_Constant, return_false);
def(AST_Super, return_false);
def(AST_This, return_false);
def(AST_Call, function(compressor){
@@ -2838,7 +2836,6 @@ merge(Compressor.prototype, {
def(AST_Node, return_this);
def(AST_Constant, return_null);
def(AST_Super, return_null);
def(AST_This, return_null);
def(AST_Call, function(compressor, first_in_statement){
if (!this.is_expr_pure(compressor)) {
@@ -4832,7 +4829,7 @@ merge(Compressor.prototype, {
var has_special_symbol = false;
self.walk(new TreeWalker(function(node) {
if (has_special_symbol) return true;
if (node instanceof AST_Super || node instanceof AST_This) {
if (node instanceof AST_This) {
has_special_symbol = true;
return true;
}

View File

@@ -1685,9 +1685,6 @@ function OutputStream(options) {
DEFPRINT(AST_Symbol, function (self, output) {
self._do_print(output);
});
DEFPRINT(AST_SymbolDeclaration, function(self, output){
self._do_print(output);
});
DEFPRINT(AST_Hole, noop);
DEFPRINT(AST_This, function(self, output){
output.print("this");

View File

@@ -631,3 +631,31 @@ issue_2271: {
}
expect_stdout: "PASS"
}
concise_method_with_super: {
options = {
arrows: true,
}
input: {
var o = {
f: "FAIL",
g() {
return super.f;
}
}
Object.setPrototypeOf(o, { f: "PASS" });
console.log(o.g());
}
expect: {
var o = {
f: "FAIL",
g() {
return super.f;
}
}
Object.setPrototypeOf(o, { f: "PASS" });
console.log(o.g());
}
expect_stdout: "PASS"
node_version: ">=4"
}