Skip to content

Commit

Permalink
refactor(transformer/class-properties): shorten code (#7804)
Browse files Browse the repository at this point in the history
Follow-on after #7798. Pure refactor, just shorten code.

I *think* `expect` has same behavior as `unreachable!` in terms of making the compiler backtrack to try to prove the check can be elided. But in this case, I doubt it can prove it either way.
  • Loading branch information
overlookmotel committed Dec 11, 2024
1 parent 54ef2b9 commit 47a91d2
Showing 1 changed file with 1 addition and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -961,11 +961,7 @@ impl<'a, 'ctx> ClassProperties<'a, 'ctx> {
let mut chain_expr = Self::convert_chain_expression_to_expression(expr, ctx);
let result = self
.transform_private_field_expression_of_chain_expression(&mut chain_expr, ctx)
.unwrap_or_else(|| {
unreachable!(
"The ChainExpression must contains at least one optional expression, so it never be `None` here."
)
});
.expect("The ChainExpression must contain at least one optional expression, so it can never be `None` here.");
Some((result, chain_expr))
} else if let Some(result) = self.transform_chain_expression_element(element, ctx) {
let chain_expr = Self::convert_chain_expression_to_expression(expr, ctx);
Expand Down

0 comments on commit 47a91d2

Please sign in to comment.