diff --git a/sway-core/src/semantic_analysis/type_check_context.rs b/sway-core/src/semantic_analysis/type_check_context.rs index fb68d4e6ca6..21a70983669 100644 --- a/sway-core/src/semantic_analysis/type_check_context.rs +++ b/sway-core/src/semantic_analysis/type_check_context.rs @@ -743,16 +743,18 @@ 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 - .namespace() - .require_module_from_absolute_path(handler, &item_prefix.to_vec())?; + let mut items = local_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); + // grab the items from where the type is declared + let mut type_items = type_module.get_items_for_type(self.engines, type_id); - let mut items = local_items; - items.append(&mut type_items); + items.append(&mut type_items); + } let mut matching_item_decl_refs: Vec = vec![];