minor clean-up (#5209)
authorAlex Lam S.L <alexlamsl@gmail.com>
Wed, 8 Dec 2021 21:14:57 +0000 (21:14 +0000)
committerGitHub <noreply@github.com>
Wed, 8 Dec 2021 21:14:57 +0000 (05:14 +0800)
lib/compress.js
test/compress/arrows.js
test/compress/awaits.js

index 5bb9bcb..3a58f35 100644 (file)
@@ -12390,9 +12390,7 @@ Compressor.prototype.compress = function(node) {
         }
     });
 
-    AST_Arrow.DEFMETHOD("contains_super", return_false);
-    AST_AsyncArrow.DEFMETHOD("contains_super", return_false);
-    AST_Lambda.DEFMETHOD("contains_super", function() {
+    AST_LambdaExpression.DEFMETHOD("contains_super", function() {
         var result;
         var self = this;
         self.walk(new TreeWalker(function(node) {
@@ -12402,8 +12400,6 @@ Compressor.prototype.compress = function(node) {
         }));
         return result;
     });
-    AST_LambdaDefinition.DEFMETHOD("contains_super", return_false);
-    AST_Scope.DEFMETHOD("contains_super", return_false);
 
     AST_Arrow.DEFMETHOD("contains_this", return_false);
     AST_AsyncArrow.DEFMETHOD("contains_this", return_false);
index 5cbf56b..54886d5 100644 (file)
@@ -363,6 +363,28 @@ negate: {
 }
 
 inline_this: {
+    options = {
+        inline: true,
+    }
+    input: {
+        var p = "PASS";
+        console.log({
+            p: "FAIL",
+            q: (() => this.p)(),
+        }.q);
+    }
+    expect: {
+        var p = "PASS";
+        console.log({
+            p: "FAIL",
+            q: this.p,
+        }.q);
+    }
+    expect_stdout: "PASS"
+    node_version: ">=4"
+}
+
+dont_inline_this: {
     options = {
         inline: true,
     }
index 7d79fe1..34479d4 100644 (file)
@@ -340,6 +340,33 @@ inline_await_3_trim: {
     node_version: ">=8"
 }
 
+inline_await_this: {
+    options = {
+        awaits: true,
+        inline: true,
+    }
+    input: {
+        var p = "FAIL";
+        ({
+            p: "PASS",
+            async f() {
+                return await (async () => this.p)();
+            },
+        }).f().then(console.log);
+    }
+    expect: {
+        var p = "FAIL";
+        ({
+            p: "PASS",
+            async f() {
+                return await this.p;
+            },
+        }).f().then(console.log);
+    }
+    expect_stdout: "PASS"
+    node_version: ">=8"
+}
+
 await_unary: {
     options = {
         awaits: true,