Skip to content

Commit 2e5ef5c

Browse files
committed
Fixes double call of get_items_for_type.
1 parent 3a9c171 commit 2e5ef5c

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

sway-core/src/semantic_analysis/type_check_context.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,20 +1183,22 @@ impl<'a> TypeCheckContext<'a> {
11831183
type_engine.insert(self.engines, TypeInfo::ErrorRecovery(err), None)
11841184
});
11851185

1186-
// grab the module where the type itself is declared
1187-
let type_module = self.namespace().lookup_submodule_from_absolute_path(
1188-
handler,
1189-
self.engines(),
1190-
item_prefix,
1191-
)?;
1186+
let mut items = local_items;
1187+
if item_prefix != self.namespace().mod_path {
1188+
// grab the module where the type itself is declared
1189+
let type_module = self.namespace().lookup_submodule_from_absolute_path(
1190+
handler,
1191+
self.engines(),
1192+
item_prefix,
1193+
)?;
11921194

1193-
// grab the items from where the type is declared
1194-
let mut type_items = type_module
1195-
.current_items()
1196-
.get_items_for_type(self.engines, type_id);
1195+
// grab the items from where the type is declared
1196+
let mut type_items = type_module
1197+
.current_items()
1198+
.get_items_for_type(self.engines, type_id);
11971199

1198-
let mut items = local_items;
1199-
items.append(&mut type_items);
1200+
items.append(&mut type_items);
1201+
}
12001202

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

0 commit comments

Comments
 (0)