@@ -1029,12 +1029,12 @@ merge(Compressor.prototype, {
|
|||||||
if (prop.key instanceof AST_Node) prop.key.walk(tw);
|
if (prop.key instanceof AST_Node) prop.key.walk(tw);
|
||||||
return prop.value;
|
return prop.value;
|
||||||
}).forEach(function(prop) {
|
}).forEach(function(prop) {
|
||||||
if (prop.static && (prop.value instanceof AST_Lambda || !prop.value.contains_this())) {
|
if (!prop.static || prop instanceof AST_ClassField && prop.value.contains_this()) {
|
||||||
prop.value.walk(tw);
|
|
||||||
} else {
|
|
||||||
push(tw);
|
push(tw);
|
||||||
prop.value.walk(tw);
|
prop.value.walk(tw);
|
||||||
pop(tw);
|
pop(tw);
|
||||||
|
} else {
|
||||||
|
prop.value.walk(tw);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
@@ -6185,12 +6185,6 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (node instanceof AST_This && scope instanceof AST_DefClass) {
|
|
||||||
var def = scope.name.definition();
|
|
||||||
if (!(def.id in in_use_ids)) {
|
|
||||||
in_use_ids[def.id] = true;
|
|
||||||
in_use.push(def);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return scan_ref_scoped(node, descend, true);
|
return scan_ref_scoped(node, descend, true);
|
||||||
});
|
});
|
||||||
@@ -7703,10 +7697,9 @@ merge(Compressor.prototype, {
|
|||||||
for (var i = 0; i < props.length; i++) {
|
for (var i = 0; i < props.length; i++) {
|
||||||
var prop = props[i];
|
var prop = props[i];
|
||||||
if (prop.key instanceof AST_Node) exprs.push(prop.key);
|
if (prop.key instanceof AST_Node) exprs.push(prop.key);
|
||||||
if (prop instanceof AST_ClassField
|
if (prop.static && prop.value
|
||||||
&& prop.static
|
&& prop instanceof AST_ClassField
|
||||||
&& prop.value
|
&& prop.value.has_side_effects(compressor)) {
|
||||||
&& !(prop.value instanceof AST_Lambda)) {
|
|
||||||
if (prop.value.contains_this()) return this;
|
if (prop.value.contains_this()) return this;
|
||||||
values.push(prop.value);
|
values.push(prop.value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -973,9 +973,9 @@ issue_4681: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
console.log(function(a) {
|
console.log(function(a) {
|
||||||
class A {
|
(class {
|
||||||
static p = a = this;
|
static p = a = this;
|
||||||
}
|
});
|
||||||
return typeof a;
|
return typeof a;
|
||||||
}());
|
}());
|
||||||
}
|
}
|
||||||
@@ -1399,9 +1399,9 @@ issue_4821_1: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
var a;
|
var a;
|
||||||
class A {
|
(class {
|
||||||
static p = void (a = this);
|
static p = void (a = this);
|
||||||
}
|
});
|
||||||
console.log(typeof a);
|
console.log(typeof a);
|
||||||
}
|
}
|
||||||
expect_stdout: "function"
|
expect_stdout: "function"
|
||||||
@@ -1725,3 +1725,26 @@ issue_4982_2: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=12"
|
node_version: ">=12"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4992: {
|
||||||
|
options = {
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
class A {
|
||||||
|
static P = this;
|
||||||
|
get p() {}
|
||||||
|
}
|
||||||
|
console.log(typeof A.P);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(typeof class {
|
||||||
|
static P = this;
|
||||||
|
get p() {}
|
||||||
|
}.P);
|
||||||
|
}
|
||||||
|
expect_stdout: "function"
|
||||||
|
node_version: ">=12"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user