diff --git a/crates/oxc_transformer/src/common/statement_injector.rs b/crates/oxc_transformer/src/common/statement_injector.rs index 52bcb988600ed..d01c9f891f86e 100644 --- a/crates/oxc_transformer/src/common/statement_injector.rs +++ b/crates/oxc_transformer/src/common/statement_injector.rs @@ -67,9 +67,9 @@ impl<'a> StatementInjectorStore<'a> { /// Add a statement to be inserted immediately before the target statement. #[expect(dead_code)] - pub fn insert_before(&self, target: Address, stmt: Statement<'a>) { + pub fn insert_before(&self, target: &Statement<'a>, stmt: Statement<'a>) { let mut insertions = self.insertions.borrow_mut(); - let adjacent_stmts = insertions.entry(target).or_default(); + let adjacent_stmts = insertions.entry(target.address()).or_default(); let index = adjacent_stmts .iter() .position(|s| matches!(s.direction, Direction::After)) @@ -79,20 +79,20 @@ impl<'a> StatementInjectorStore<'a> { /// Add a statement to be inserted immediately after the target statement. #[expect(dead_code)] - pub fn insert_after(&self, target: Address, stmt: Statement<'a>) { + pub fn insert_after(&self, target: &Statement<'a>, stmt: Statement<'a>) { let mut insertions = self.insertions.borrow_mut(); - let adjacent_stmts = insertions.entry(target).or_default(); + let adjacent_stmts = insertions.entry(target.address()).or_default(); adjacent_stmts.push(AdjacentStatement { stmt, direction: Direction::After }); } /// Add multiple statements to be inserted immediately before the target statement. #[expect(dead_code)] - pub fn insert_many_before(&self, target: Address, stmts: S) + pub fn insert_many_before(&self, target: &Statement<'a>, stmts: S) where S: IntoIterator>, { let mut insertions = self.insertions.borrow_mut(); - let adjacent_stmts = insertions.entry(target).or_default(); + let adjacent_stmts = insertions.entry(target.address()).or_default(); adjacent_stmts.splice( 0..0, stmts.into_iter().map(|stmt| AdjacentStatement { stmt, direction: Direction::Before }), @@ -100,12 +100,12 @@ impl<'a> StatementInjectorStore<'a> { } /// Add multiple statements to be inserted immediately after the target statement. - pub fn insert_many_after(&self, target: Address, stmts: S) + pub fn insert_many_after(&self, target: &Statement<'a>, stmts: S) where S: IntoIterator>, { let mut insertions = self.insertions.borrow_mut(); - let adjacent_stmts = insertions.entry(target).or_default(); + let adjacent_stmts = insertions.entry(target.address()).or_default(); adjacent_stmts.extend( stmts.into_iter().map(|stmt| AdjacentStatement { stmt, direction: Direction::After }), ); diff --git a/crates/oxc_transformer/src/typescript/annotations.rs b/crates/oxc_transformer/src/typescript/annotations.rs index 943f390700188..d96b00007f0c5 100644 --- a/crates/oxc_transformer/src/typescript/annotations.rs +++ b/crates/oxc_transformer/src/typescript/annotations.rs @@ -4,7 +4,7 @@ use std::cell::Cell; use rustc_hash::FxHashSet; -use oxc_allocator::{GetAddress, Vec as ArenaVec}; +use oxc_allocator::Vec as ArenaVec; use oxc_ast::ast::*; use oxc_diagnostics::OxcDiagnostic; use oxc_semantic::SymbolFlags; @@ -414,7 +414,7 @@ impl<'a, 'ctx> Traverse<'a> for TypeScriptAnnotations<'a, 'ctx> { // Add assignments after super calls self.ctx.statement_injector.insert_many_after( - stmt.address(), + stmt, self.assignments .iter() .map(|assignment| assignment.create_this_property_assignment(ctx)),