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
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,10 @@ impl<'a, 'c> ConstructorParamsSuperReplacer<'a, 'c> {

/// Create `_super` function to go outside class.
/// `function() { <inits>; return this; }`
//
// TODO(improve-on-babel): When not in loose mode, inits are `_defineProperty(this, propName, value)`.
// `_defineProperty` returns `this`, so last statement could be `return _defineProperty(this, propName, value)`,
// rather than an additional `return this` statement.
fn create_super_func(inits: Vec<Expression<'a>>, ctx: &mut TraverseCtx<'a>) -> Expression<'a> {
let outer_scope_id = ctx.current_scope_id();
let super_func_scope_id = ctx.scopes_mut().add_scope(
Expand Down Expand Up @@ -518,6 +522,10 @@ impl<'a, 'c> ConstructorBodyInitsInserter<'a, 'c> {
ctx.generate_uid("args", super_func_scope_id, SymbolFlags::FunctionScopedVariable);

// `super(..._args); <inits>; return this;`
//
// TODO(improve-on-babel): When not in loose mode, inits are `_defineProperty(this, propName, value)`.
// `_defineProperty` returns `this`, so last statement could be `return _defineProperty(this, propName, value)`,
// rather than an additional `return this` statement.
let super_call = create_super_call_stmt(&args_binding, ctx);
let return_stmt = ctx.ast.statement_return(SPAN, Some(ctx.ast.expression_this(SPAN)));
let body_stmts = ctx.ast.vec_from_iter(
Expand Down