Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions crates/oxc_transformer/src/es2015/arrow_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl<'a> Traverse<'a> for ArrowFunctions<'a> {
return;
}

let ident = self.get_this_name(ctx).create_spanned_read_reference(this.span, ctx);
let ident = self.get_this_identifier(this.span, ctx);
*element_name = self.ctx.ast.jsx_element_name_from_identifier_reference(ident);
};
}
Expand All @@ -193,7 +193,7 @@ impl<'a> Traverse<'a> for ArrowFunctions<'a> {
return;
}

let ident = self.get_this_name(ctx).create_spanned_read_reference(this.span, ctx);
let ident = self.get_this_identifier(this.span, ctx);
*object = self.ctx.ast.jsx_member_expression_object_from_identifier_reference(ident);
}
}
Expand All @@ -204,7 +204,7 @@ impl<'a> Traverse<'a> for ArrowFunctions<'a> {
return;
}

let ident = self.get_this_name(ctx).create_spanned_read_reference(this_expr.span, ctx);
let ident = self.get_this_identifier(this_expr.span, ctx);
*expr = self.ctx.ast.expression_from_identifier_reference(ident);
}
}
Expand Down Expand Up @@ -241,7 +241,11 @@ impl<'a> ArrowFunctions<'a> {
*self.inside_arrow_function_stack.last().unwrap()
}

fn get_this_name(&mut self, ctx: &mut TraverseCtx<'a>) -> BoundIdentifier<'a> {
fn get_this_identifier(
&mut self,
span: Span,
ctx: &mut TraverseCtx<'a>,
) -> IdentifierReference<'a> {
let this_var = self.this_var_stack.last_mut().unwrap();
if this_var.is_none() {
let target_scope_id =
Expand All @@ -258,7 +262,8 @@ impl<'a> ArrowFunctions<'a> {
ctx,
));
}
this_var.as_ref().unwrap().clone()
let this_var = this_var.as_ref().unwrap();
this_var.create_spanned_read_reference(span, ctx)
}

fn transform_arrow_function_expression(
Expand Down