Repository: swc-project/swc (rust)

Issue:
es2021: `super` in a private method is not transpiled
### Describe the bug

`super` is not replaced so the output is broken like

```
Caused by:
    failed to execute:

    [eval]:38
        return super.superMethod();
               ^^^^^

    SyntaxError: 'super' keyword unexpected here
        at new Script (node:vm:100:7)
        at createScript (node:vm:257:10)
        at Object.runInThisContext (node:vm:305:10)
        at node:internal/process/execution:76:19
        at [eval]-wrapper:6:22
        at evalScript (node:internal/process/execution:75:60)
        at node:internal/main/eval_string:27:3
```

### Input code

```typescript
class Base {
  superMethod() {
    return 'good';
  }
}

class Sub extends Base {
  superMethod() {
    return 'bad';
  }

  #privateMethod() {
    return super.superMethod();
  }

  publicMethod() {
    return this.#privateMethod();
  }
}

(new Sub()).publicMethod().toEqual('good');
```


### Config

```json
{
  "jsc": {
    "parser": {
      "syntax": "ecmascript"
    },
    "target": "es2021",
    "minify": {
      "compress": false,
      "mangle": false
    },
    "loose": false
  },
  "minify": false
}
```


### Playground link

https://play.swc.rs/?version=1.2.241&code=H4sIAAAAAAAAA0vOSSwuVnBKLE5VqOZSUCguLUgt8k0tychP0dAEiygoFKWWlBblKain5%2BenqFsDhWq5arm4ksEag0uTFFIrSlLzUog0JCkRZgaQUC4oyixLLEnFrhZsjB6KYXCdBaVJOZnJ2PWVZGQW66EbDXe3Rl5qOcjZGpqaeqim6JXkuxaWJuZoQHwK1AIA39pcAh0BAAA%3D&config=H4sIAAAAAAAAA02LywqEMBAE%2F6XPHtRj%2FmYIE8mSF9M5rMj%2B%2BxpU8NbVRR340MMdaGJUG4t76fKFg%2Fos9BZbx29CF9u0j5vrvC6YkGOJYR%2BJr7mZknBBEvVUUrakN55xqpUvfMqL%2F63bUfaEAAAA

### Expected behavior

It should success

### Actual behavior

_No response_

### Version

1.2.241

### Additional context

Found by https://github.com/swc-project/swc/pull/5578

Pull request:
fix(es/compat): Handle super in private method
- fix #5596 

Patch:
diff --git a/crates/swc_ecma_transforms_compat/src/es2022/class_properties/mod.rs b/crates/swc_ecma_transforms_compat/src/es2022/class_properties/mod.rs
index ab2f5751a8..ed219d3ed6 100644
--- a/crates/swc_ecma_transforms_compat/src/es2022/class_properties/mod.rs
+++ b/crates/swc_ecma_transforms_compat/src/es2022/class_properties/mod.rs
@@ -742,7 +742,7 @@ impl<C: Comments> ClassProperties<C> {
                     constructor = Some(c);
                 }
 
-                ClassMember::PrivateMethod(method) => {
+                ClassMember::PrivateMethod(mut method) => {
                     let is_static = method.is_static;
                     let prop_span = method.span;
 
@@ -875,6 +875,20 @@ impl<C: Comments> ClassProperties<C> {
                         })
                     };
 
+                    method.function.visit_mut_with(&mut SuperFieldAccessFolder {
+                        class_name: &class_ident,
+                        vars: &mut vars,
+                        constructor_this_mark: None,
+                        is_static,
+                        folding_constructor: false,
+                        in_injected_define_property_call: false,
+                        in_nested_scope: false,
+                        this_alias_mark: None,
+                        constant_super: self.c.constant_super,
+                        super_class: &super_ident,
+                        in_pat: false,
+                    });
+
                     private_method_fn_decls.push(Stmt::Decl(Decl::Fn(FnDecl {
                         ident: fn_name,
                         function: method.function,


Test patch:
diff --git a/crates/swc/tests/babel-exec/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method-loose/.super/exec.js b/crates/swc/tests/babel-exec/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method-loose/super/exec.js
similarity index 100%
rename from crates/swc/tests/babel-exec/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method-loose/.super/exec.js
rename to crates/swc/tests/babel-exec/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method-loose/super/exec.js
diff --git a/crates/swc/tests/babel-exec/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/.super/exec.js b/crates/swc/tests/babel-exec/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/super/exec.js
similarity index 100%
rename from crates/swc/tests/babel-exec/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/.super/exec.js
rename to crates/swc/tests/babel-exec/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/super/exec.js
diff --git a/crates/swc/tests/fixture/issues-5xxx/5596/input/.swcrc b/crates/swc/tests/fixture/issues-5xxx/5596/input/.swcrc
new file mode 100644
index 0000000000..a97302928a
--- /dev/null
+++ b/crates/swc/tests/fixture/issues-5xxx/5596/input/.swcrc
@@ -0,0 +1,14 @@
+{
+    "jsc": {
+        "parser": {
+            "syntax": "ecmascript"
+        },
+        "target": "es2021",
+        "minify": {
+            "compress": false,
+            "mangle": false
+        },
+        "loose": false
+    },
+    "minify": false
+}
\ No newline at end of file
diff --git a/crates/swc/tests/fixture/issues-5xxx/5596/input/index.js b/crates/swc/tests/fixture/issues-5xxx/5596/input/index.js
new file mode 100644
index 0000000000..b8f4b7956b
--- /dev/null
+++ b/crates/swc/tests/fixture/issues-5xxx/5596/input/index.js
@@ -0,0 +1,21 @@
+class Base {
+    superMethod() {
+      return 'good';
+    }
+  }
+  
+  class Sub extends Base {
+    superMethod() {
+      return 'bad';
+    }
+  
+    #privateMethod() {
+      return super.superMethod();
+    }
+  
+    publicMethod() {
+      return this.#privateMethod();
+    }
+  }
+  
+  (new Sub()).publicMethod().toEqual('good');
\ No newline at end of file
diff --git a/crates/swc/tests/fixture/issues-5xxx/5596/output/index.js b/crates/swc/tests/fixture/issues-5xxx/5596/output/index.js
new file mode 100644
index 0000000000..a05ebac321
--- /dev/null
+++ b/crates/swc/tests/fixture/issues-5xxx/5596/output/index.js
@@ -0,0 +1,26 @@
+import _class_private_method_get from "@swc/helpers/src/_class_private_method_get.mjs";
+import _class_private_method_init from "@swc/helpers/src/_class_private_method_init.mjs";
+import _get from "@swc/helpers/src/_get.mjs";
+import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
+class Base {
+    superMethod() {
+        return 'good';
+    }
+}
+var _privateMethod = new WeakSet();
+class Sub extends Base {
+    superMethod() {
+        return 'bad';
+    }
+    publicMethod() {
+        return _class_private_method_get(this, _privateMethod, privateMethod).call(this);
+    }
+    constructor(...args){
+        super(...args);
+        _class_private_method_init(this, _privateMethod);
+    }
+}
+function privateMethod() {
+    return _get(_get_prototype_of(Sub.prototype), "superMethod", this).call(this);
+}
+new Sub().publicMethod().toEqual('good');