File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed
crates/oxc_transformer/src/es2022/class_properties Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -641,17 +641,18 @@ impl<'a> ClassProperties<'a, '_> {
641
641
642
642
// Insert private methods
643
643
if !self . insert_after_stmts . is_empty ( ) {
644
- // Find address of statement of class expression
645
- let position = ctx
646
- . ancestors ( )
647
- . position ( Ancestor :: is_parent_of_statement)
648
- . expect ( "Expression always inside a statement." ) ;
649
- // Position points to parent of statement, we need to find the statement itself,
650
- // so `position - 1`.
651
- let stmt_ancestor = ctx. ancestor ( position - 1 ) ;
644
+ // Find `Address` of statement containing class expression
645
+ let mut stmt_address = Address :: DUMMY ;
646
+ for ancestor in ctx. ancestors ( ) {
647
+ if ancestor. is_parent_of_statement ( ) {
648
+ break ;
649
+ }
650
+ stmt_address = ancestor. address ( ) ;
651
+ }
652
+
652
653
self . ctx
653
654
. statement_injector
654
- . insert_many_after ( & stmt_ancestor , self . insert_after_stmts . drain ( ..) ) ;
655
+ . insert_many_after ( & stmt_address , self . insert_after_stmts . drain ( ..) ) ;
655
656
}
656
657
657
658
// Insert computed key initializers
You can’t perform that action at this time.
0 commit comments