Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes double call of get_items_for_type. #6626

Merged
merged 2 commits into from
Feb 7, 2025
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
30 changes: 16 additions & 14 deletions sway-core/src/semantic_analysis/type_check_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -719,14 +719,6 @@ impl<'a> TypeCheckContext<'a> {
return Err(*err);
}

// grab the local module
let local_module = self
.namespace()
.require_module_from_absolute_path(handler, &self.namespace().current_mod_path)?;

// grab the local items from the local module
let local_items = local_module.get_items_for_type(self.engines, type_id);

// resolve the type
let type_id = resolve_type(
handler,
Expand All @@ -743,16 +735,26 @@ impl<'a> TypeCheckContext<'a> {
)
.unwrap_or_else(|err| type_engine.id_of_error_recovery(err));

// grab the module where the type itself is declared
let type_module = self
// grab the local module
let local_module = self
.namespace()
.require_module_from_absolute_path(handler, &item_prefix.to_vec())?;
.require_module_from_absolute_path(handler, &self.namespace().current_mod_path)?;

// grab the items from where the type is declared
let mut type_items = type_module.get_items_for_type(self.engines, type_id);
// grab the local items from the local module
let local_items = local_module.get_items_for_type(self.engines, type_id);

let mut items = local_items;
items.append(&mut type_items);
if item_prefix.to_vec() != self.namespace().current_mod_path {
// grab the module where the type itself is declared
let type_module = self
.namespace()
.require_module_from_absolute_path(handler, &item_prefix.to_vec())?;

// grab the items from where the type is declared
let mut type_items = type_module.get_items_for_type(self.engines, type_id);

items.append(&mut type_items);
}

let mut matching_item_decl_refs: Vec<ty::TyTraitItem> = vec![];

Expand Down
Loading