Skip to content

Commit

Permalink
refactor(transformer/arrow-functions): use scope_id method (#7164)
Browse files Browse the repository at this point in the history
Follow-on after #7125. Use `scope_id` method introduced in #7127.
  • Loading branch information
overlookmotel committed Nov 6, 2024
1 parent 11c5e12 commit 426df71
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions crates/oxc_transformer/src/common/arrow_function_converter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,10 @@ impl<'a> Traverse<'a> for ArrowFunctionConverter<'a> {
}

if let Some(this_var) = self.this_var_stack.take_last() {
let target_scope_id = program.scope_id();
self.insert_this_var_statement_at_the_top_of_statements(
&mut program.body,
program.scope_id.get().unwrap(),
target_scope_id,
&this_var,
ctx,
);
Expand Down Expand Up @@ -180,11 +181,12 @@ impl<'a> Traverse<'a> for ArrowFunctionConverter<'a> {
}

if let Some(this_var) = self.this_var_stack.pop() {
let target_scope_id = func.scope_id();
let Some(body) = &mut func.body else { unreachable!() };

self.insert_this_var_statement_at_the_top_of_statements(
&mut body.statements,
func.scope_id.get().unwrap(),
target_scope_id,
&this_var,
ctx,
);
Expand All @@ -205,9 +207,10 @@ impl<'a> Traverse<'a> for ArrowFunctionConverter<'a> {
}

if let Some(this_var) = self.this_var_stack.pop() {
let target_scope_id = block.scope_id();
self.insert_this_var_statement_at_the_top_of_statements(
&mut block.body,
block.scope_id.get().unwrap(),
target_scope_id,
&this_var,
ctx,
);
Expand Down

0 comments on commit 426df71

Please sign in to comment.