@@ -173,19 +173,23 @@ impl<'hir> Visit<'hir> for BytecodeDependencyCollector<'hir> {
173173
174174 fn visit_expr ( & mut self , expr : & ' hir Expr < ' hir > ) -> ControlFlow < Self :: BreakValue > {
175175 match & expr. kind {
176- ExprKind :: New ( ty) => {
177- if let TypeKind :: Custom ( item_id) = ty. kind {
178- if let Some ( contract_id) = item_id. as_contract ( ) {
179- let name_loc = SourceMapLocation :: from_span ( self . source_map , ty. span ) ;
180- let name = & self . src [ name_loc. start ..name_loc. end ] ;
181- // TODO: check if there's a better way to determine where constructor call
182- // ends.
183- let args_len = self . src [ name_loc. end ..] . split_once ( ';' ) . unwrap ( ) . 0 . len ( ) ;
184- self . collect_dependency ( BytecodeDependency {
185- kind : BytecodeDependencyKind :: New ( name. to_string ( ) , args_len) ,
186- loc : SourceMapLocation :: from_span ( self . source_map , expr. span ) ,
187- referenced_contract : contract_id,
188- } ) ;
176+ ExprKind :: Call ( ty, _, _) => {
177+ if let ExprKind :: New ( ty_new) = & ty. kind {
178+ if let TypeKind :: Custom ( item_id) = ty_new. kind {
179+ if let Some ( contract_id) = item_id. as_contract ( ) {
180+ let name_loc =
181+ SourceMapLocation :: from_span ( self . source_map , ty_new. span ) ;
182+ let name = & self . src [ name_loc. start ..name_loc. end ] ;
183+ let args_len = expr. span . hi ( ) - ty_new. span . hi ( ) ;
184+ self . collect_dependency ( BytecodeDependency {
185+ kind : BytecodeDependencyKind :: New (
186+ name. to_string ( ) ,
187+ args_len. to_usize ( ) ,
188+ ) ,
189+ loc : SourceMapLocation :: from_span ( self . source_map , ty. span ) ,
190+ referenced_contract : contract_id,
191+ } ) ;
192+ }
189193 }
190194 }
191195 }
0 commit comments