Unverified Commit d06c5476 authored by Shu Ding's avatar Shu Ding Committed by GitHub

Fix the method prop case in Server Actions transform (#64398)

This PR fixes the case where object method and class method prop
functions are not considered as a new scope. Closes #63603.

Closes NEXT-3088
parent 52ae1f8a
...@@ -572,6 +572,26 @@ impl<C: Comments> VisitMut for ServerActions<C> { ...@@ -572,6 +572,26 @@ impl<C: Comments> VisitMut for ServerActions<C> {
} }
} }
fn visit_mut_method_prop(&mut self, m: &mut MethodProp) {
let old_in_export_decl = self.in_export_decl;
let old_in_default_export_decl = self.in_default_export_decl;
self.in_export_decl = false;
self.in_default_export_decl = false;
m.visit_mut_children_with(self);
self.in_export_decl = old_in_export_decl;
self.in_default_export_decl = old_in_default_export_decl;
}
fn visit_mut_class_method(&mut self, m: &mut ClassMethod) {
let old_in_export_decl = self.in_export_decl;
let old_in_default_export_decl = self.in_default_export_decl;
self.in_export_decl = false;
self.in_default_export_decl = false;
m.visit_mut_children_with(self);
self.in_export_decl = old_in_export_decl;
self.in_default_export_decl = old_in_default_export_decl;
}
fn visit_mut_arrow_expr(&mut self, a: &mut ArrowExpr) { fn visit_mut_arrow_expr(&mut self, a: &mut ArrowExpr) {
// Arrow expressions need to be visited in prepass to determine if it's // Arrow expressions need to be visited in prepass to determine if it's
// an action function or not. // an action function or not.
......
'use server'
export const action = {
async f(x) {
;(() => {
console.log(x)
})()
},
}.f
export const action2 = new (class X {
async f(x) {
;(() => {
console.log(x)
})()
}
})().f
/* __next_internal_action_entry_do_not_use__ {"abf760c735ba66c4c26a2913864dd7e28fb88a91":"action2","f14702b5a021dd117f7ec7a3c838f397c2046d3b":"action"} */ import { registerServerReference } from "private-next-rsc-server-reference";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
export const action = {
async f (x) {
;
(()=>{
console.log(x);
})();
}
}.f;
export const action2 = new class X {
async f(x) {
;
(()=>{
console.log(x);
})();
}
}().f;
import { ensureServerEntryExports } from "private-next-rsc-action-validate";
ensureServerEntryExports([
action,
action2
]);
registerServerReference("f14702b5a021dd117f7ec7a3c838f397c2046d3b", action);
registerServerReference("abf760c735ba66c4c26a2913864dd7e28fb88a91", action2);
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment