Skip to content

Commit

Permalink
refactor(transformer/class-properties): de-deduplicate code (#7805)
Browse files Browse the repository at this point in the history
Follow-on after #7798. Pure refactor. Include `transform_chain_element_recursively` call once instead of twice.
  • Loading branch information
overlookmotel committed Dec 11, 2024
1 parent 47a91d2 commit afc5f1e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions crates/oxc_transformer/src/es2022/class_properties/private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1159,8 +1159,9 @@ impl<'a, 'ctx> ClassProperties<'a, 'ctx> {
return result;
}

let result = self.transform_chain_element_recursively(callee, ctx);
if !is_optional {
return self.transform_chain_element_recursively(callee, ctx);
return result;
}

// `o?.Foo.#self.getSelf?.()?.self.#m();`
Expand All @@ -1169,7 +1170,7 @@ impl<'a, 'ctx> ClassProperties<'a, 'ctx> {
// then use it as a first argument of `getSelf` call.
//
// TODO(improve-on-babel): Consider remove this logic, because it seems no runtime behavior change.
let result = self.transform_chain_element_recursively(callee, ctx)?;
let result = result?;
let object = callee.to_member_expression_mut().object_mut();
let (assignment, context) = self.duplicate_object(ctx.ast.move_expression(object), ctx);
*object = assignment;
Expand Down

0 comments on commit afc5f1e

Please sign in to comment.