Skip to content

Commit 3d7b4bb

Browse files
committed
Fixes double call of get_items_for_type.
1 parent 95a86ec commit 3d7b4bb

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

sway-core/src/semantic_analysis/type_check_context.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -743,16 +743,18 @@ impl<'a> TypeCheckContext<'a> {
743743
)
744744
.unwrap_or_else(|err| type_engine.id_of_error_recovery(err));
745745

746-
// grab the module where the type itself is declared
747-
let type_module = self
748-
.namespace()
749-
.require_module_from_absolute_path(handler, &item_prefix.to_vec())?;
746+
let mut items = local_items;
747+
if item_prefix.to_vec() != self.namespace().current_mod_path {
748+
// grab the module where the type itself is declared
749+
let type_module = self
750+
.namespace()
751+
.require_module_from_absolute_path(handler, &item_prefix.to_vec())?;
750752

751-
// grab the items from where the type is declared
752-
let mut type_items = type_module.get_items_for_type(self.engines, type_id);
753+
// grab the items from where the type is declared
754+
let mut type_items = type_module.get_items_for_type(self.engines, type_id);
753755

754-
let mut items = local_items;
755-
items.append(&mut type_items);
756+
items.append(&mut type_items);
757+
}
756758

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

0 commit comments

Comments
 (0)