resolver: Handle constructor properly (#1054)

This commit is contained in:
강동윤 2020-09-10 10:48:26 +09:00 committed by GitHub
parent 3a26d3d34d
commit e2546e0100
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 4 deletions

View File

@ -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"]

View File

@ -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.