Skip to content

Commit

Permalink
resolver: Handle constructor properly (#1054)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 authored Sep 10, 2020
1 parent 3a26d3d commit e2546e0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ecmascript/transforms/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecma_transforms"
repository = "https://github.com/swc-project/swc.git"
version = "0.23.5"
version = "0.23.6"

[features]
const-modules = ["dashmap"]
Expand Down
16 changes: 13 additions & 3 deletions ecmascript/transforms/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -692,13 +692,23 @@ impl<'a> VisitMut for Resolver<'a> {
}

fn visit_mut_constructor(&mut self, c: &mut Constructor) {
let child_mark = Mark::fresh(self.mark);

// Child folder
let mut folder = Resolver::new(
child_mark,
Scope::new(ScopeKind::Fn, Some(&self.current)),
None,
self.handle_types,
);

let old = self.ident_type;
self.ident_type = IdentType::Binding;
c.params.visit_mut_with(self);
c.params.visit_mut_with(&mut folder);
self.ident_type = old;

c.body.visit_mut_with(self);
c.key.visit_mut_with(self);
c.body.visit_mut_with(&mut folder);
c.key.visit_mut_with(&mut folder);
}

/// Leftmost one of a member expression should be resolved.
Expand Down

0 comments on commit e2546e0

Please sign in to comment.