File tree Expand file tree Collapse file tree
crates/wac-parser/src/resolution Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1950,19 +1950,31 @@ impl<'a> AstResolver<'a> {
19501950 uses : IndexMap < InterfaceId , IndexSet < usize > > ,
19511951 ) -> IndexMap < InterfaceId , IndexSet < usize > > {
19521952 // Now update all the interface ids in the usings
1953- uses. into_iter ( )
1954- . map ( |( dep, exports) | {
1955- let import =
1956- & state. imports [ self . definitions . interfaces [ dep] . id . as_deref ( ) . unwrap ( ) ] ;
1957- match & state. current . items [ import. item ] {
1958- super :: Item :: Import ( super :: Import {
1959- kind : ItemKind :: Instance ( id) ,
1960- ..
1961- } ) => ( * id, exports) ,
1962- _ => unreachable ! ( ) ,
1953+ let mut remapped: IndexMap < InterfaceId , IndexSet < usize > > =
1954+ IndexMap :: with_capacity ( uses. len ( ) ) ;
1955+ for ( old_id, exports) in uses {
1956+ let old = & self . definitions . interfaces [ old_id] ;
1957+ let import = & state. imports [ old. id . as_deref ( ) . unwrap ( ) ] ;
1958+ match & state. current . items [ import. item ] {
1959+ super :: Item :: Import ( super :: Import {
1960+ kind : ItemKind :: Instance ( new_id) ,
1961+ ..
1962+ } ) => {
1963+ let new = & self . definitions . interfaces [ * new_id] ;
1964+ remapped
1965+ . entry ( * new_id)
1966+ . or_default ( )
1967+ . extend ( exports. into_iter ( ) . map ( |old_index| {
1968+ new. exports
1969+ . get_index_of ( old. exports . get_index ( old_index) . unwrap ( ) . 0 )
1970+ . unwrap ( )
1971+ } ) ) ;
19631972 }
1964- } )
1965- . collect ( )
1973+ _ => unreachable ! ( ) ,
1974+ }
1975+ }
1976+
1977+ remapped
19661978 }
19671979
19681980 fn named_instantiation_arg (
You can’t perform that action at this time.
0 commit comments