Skip to content
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
34 changes: 34 additions & 0 deletions meld-core/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,40 @@ fn build_resource_type_to_import(
}
}

// Step 6: Propagate entries through resource type aliases.
//
// Function parameter types may reference a resource via an ExportAlias
// (e.g., Borrow(24) where type 24 is ExportAlias(25)). The canonical
// ResourceRep/ResourceNew entries use the target type (25). We need
// the map to also contain the alias source so resolve_resource_positions
// can find the import for either type ID.
let known_resource_types: Vec<u32> = map
.keys()
.map(|&(rt, _)| rt)
.collect::<std::collections::HashSet<_>>()
.into_iter()
.collect();
for (idx, def) in component.component_type_defs.iter().enumerate() {
if let crate::parser::ComponentTypeDef::ExportAlias(target) = def {
let alias_id = idx as u32;
let target_id = *target;
for kind in &["[resource-rep]", "[resource-new]"] {
if known_resource_types.contains(&target_id)
&& !map.contains_key(&(alias_id, kind))
&& let Some(entry) = map.get(&(target_id, kind)).cloned()
{
map.insert((alias_id, kind), entry);
}
if known_resource_types.contains(&alias_id)
&& !map.contains_key(&(target_id, kind))
&& let Some(entry) = map.get(&(alias_id, kind)).cloned()
{
map.insert((target_id, kind), entry);
}
}
}
}

map
}

Expand Down
Loading