mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
refactor(semantic): reusing the same reference (#4529)
A minor improvement
This commit is contained in:
parent
c6a11bed1d
commit
d914b14275
1 changed files with 6 additions and 6 deletions
|
|
@ -438,25 +438,25 @@ impl<'a> SemanticBuilder<'a> {
|
|||
|| flag.is_value() && symbol_flag.can_be_referenced_by_value()
|
||||
|| flag.is_ts_type_query() && symbol_flag.is_import()
|
||||
{
|
||||
let reference = &mut self.symbols.references[*id];
|
||||
// The non type-only ExportSpecifier can reference a type/value symbol,
|
||||
// If the symbol is a value symbol and reference flag is not type-only, remove the type flag.
|
||||
if symbol_flag.is_value() && !flag.is_type_only() {
|
||||
*self.symbols.references[*id].flag_mut() -= ReferenceFlag::Type;
|
||||
*reference.flag_mut() -= ReferenceFlag::Type;
|
||||
} else {
|
||||
// If the symbol is a type symbol and reference flag is not type-only, remove the value flag.
|
||||
*self.symbols.references[*id].flag_mut() -= ReferenceFlag::Value;
|
||||
*reference.flag_mut() -= ReferenceFlag::Value;
|
||||
}
|
||||
|
||||
// import type { T } from './mod'; type A = typeof T
|
||||
// ^ can reference type-only import
|
||||
// If symbol is type-import, we need to replace the ReferenceFlag::Value with ReferenceFlag::Type
|
||||
if flag.is_ts_type_query() && symbol_flag.is_type_import() {
|
||||
let reference_flag = self.symbols.references[*id].flag_mut();
|
||||
*reference_flag -= ReferenceFlag::Value;
|
||||
*reference_flag |= ReferenceFlag::Type;
|
||||
*reference.flag_mut() -= ReferenceFlag::Value;
|
||||
*reference.flag_mut() |= ReferenceFlag::Type;
|
||||
}
|
||||
|
||||
self.symbols.references[*id].set_symbol_id(symbol_id);
|
||||
reference.set_symbol_id(symbol_id);
|
||||
resolved_references.push(*id);
|
||||
false
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue