Skip to content

Commit

Permalink
Fixes double call of get_items_for_type. (#6626)
Browse files Browse the repository at this point in the history
## Description


## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.

Co-authored-by: Joshua Batty <[email protected]>
  • Loading branch information
esdrubal and JoshuaBatty authored Feb 7, 2025
1 parent 1270bfa commit b7123c5
Showing 1 changed file with 16 additions and 14 deletions.
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

0 comments on commit b7123c5

Please sign in to comment.