mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +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_value() && symbol_flag.can_be_referenced_by_value()
|
||||||
|| flag.is_ts_type_query() && symbol_flag.is_import()
|
|| 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,
|
// 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 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() {
|
if symbol_flag.is_value() && !flag.is_type_only() {
|
||||||
*self.symbols.references[*id].flag_mut() -= ReferenceFlag::Type;
|
*reference.flag_mut() -= ReferenceFlag::Type;
|
||||||
} else {
|
} else {
|
||||||
// If the symbol is a type symbol and reference flag is not type-only, remove the value flag.
|
// 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
|
// import type { T } from './mod'; type A = typeof T
|
||||||
// ^ can reference type-only import
|
// ^ can reference type-only import
|
||||||
// If symbol is type-import, we need to replace the ReferenceFlag::Value with ReferenceFlag::Type
|
// 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() {
|
if flag.is_ts_type_query() && symbol_flag.is_type_import() {
|
||||||
let reference_flag = self.symbols.references[*id].flag_mut();
|
*reference.flag_mut() -= ReferenceFlag::Value;
|
||||||
*reference_flag -= ReferenceFlag::Value;
|
*reference.flag_mut() |= ReferenceFlag::Type;
|
||||||
*reference_flag |= ReferenceFlag::Type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.symbols.references[*id].set_symbol_id(symbol_id);
|
reference.set_symbol_id(symbol_id);
|
||||||
resolved_references.push(*id);
|
resolved_references.push(*id);
|
||||||
false
|
false
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue