@@ -13,7 +13,6 @@ use crate::{
1313use alloy_primitives:: hex;
1414use foundry_compilers_artifacts:: { SolcLanguage , Source } ;
1515use foundry_compilers_core:: { error:: SolcError , utils} ;
16- use itertools:: Itertools ;
1716use md5:: Digest ;
1817use solar_parse:: {
1918 ast:: { FunctionKind , ItemKind , Span , Visibility } ,
@@ -65,14 +64,19 @@ impl Preprocessor<SolcCompiler> for TestOptimizerPreprocessor {
6564 }
6665 // Load and parse test and script contracts only (dependencies are automatically
6766 // resolved).
68- let preprocessed_paths = sources
69- . into_iter ( )
70- . filter ( |( path, source) | {
71- is_test_or_script ( path, paths) && !source. content . is_empty ( )
72- } )
73- . map ( |( path, _) | path. clone ( ) )
74- . collect_vec ( ) ;
75- parsing_context. load_files ( & preprocessed_paths) ?;
67+
68+ let mut preprocessed_paths = vec ! [ ] ;
69+ for ( path, source) in sources. iter ( ) {
70+ if is_test_or_script ( path, paths) && !source. content . is_empty ( ) {
71+ if let Ok ( src_file) = sess
72+ . source_map ( )
73+ . new_dummy_source_file ( path. clone ( ) , source. content . to_string ( ) )
74+ {
75+ parsing_context. add_file ( src_file) ;
76+ preprocessed_paths. push ( path. clone ( ) ) ;
77+ }
78+ }
79+ }
7680
7781 let hir_arena = ThreadLocal :: new ( ) ;
7882 if let Some ( gcx) = parsing_context. parse_and_lower ( & hir_arena) ? {
0 commit comments