Skip to content

Commit

Permalink
fix(fast_check): regression in cache with diagnostics (#404)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Feb 24, 2024
1 parent e3c6875 commit 1c7d36c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
11 changes: 3 additions & 8 deletions src/fast_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ pub fn build_fast_check_type_graph<'a>(

let mut fast_check_modules =
Vec::with_capacity(package.module_ranges.len());
if package.sources.is_empty() {
if package.cache_items.is_empty() {
transform_package(
package.module_ranges,
root_symbol,
Expand Down Expand Up @@ -530,13 +530,8 @@ pub fn build_fast_check_type_graph<'a>(
final_result.extend(fast_check_modules);
}
} else {
// these were sources in the cache, so use those
final_result.extend(
package
.sources
.into_iter()
.map(|(url, module_item)| (url, Ok(module_item))),
);
// use the items from the cache
final_result.extend(package.cache_items);
}

if !errors.is_empty() {
Expand Down
22 changes: 12 additions & 10 deletions src/fast_check/range_finder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,11 @@ pub struct PackagePublicRanges {
// uses an IndexMap to maintain order so that when transforming
// it goes over the modules in the exact same deterministic order
pub module_ranges: IndexMap<ModuleSpecifier, ModulePublicRanges>,
pub sources: Vec<(ModuleSpecifier, FastCheckModule)>,
/// Items loaded from the cache. If set, these should be used over module_ranges.
pub cache_items: Vec<(
ModuleSpecifier,
Result<FastCheckModule, Vec<FastCheckDiagnostic>>,
)>,
pub dependencies: BTreeSet<PackageNv>,
}

Expand Down Expand Up @@ -466,23 +470,21 @@ impl<'a> PublicRangeFinder<'a> {
let Ok(module_info) = serde_json::from_str(&info.module_info) else {
return None;
};
package.sources.push((
package.cache_items.push((
url,
FastCheckModule {
Ok(FastCheckModule {
module_info: Arc::new(module_info),
text: info.text,
source_map: info.source_map,
dts: None,
},
}),
));
}
super::cache::FastCheckCacheModuleItem::Diagnostic(_) => {
package
.module_ranges
.entry(url.clone())
.or_default()
.diagnostics
.push(FastCheckDiagnostic::Cached { specifier: url });
package.cache_items.push((
url.clone(),
Err(vec![FastCheckDiagnostic::Cached { specifier: url }]),
));
}
}
}
Expand Down

0 comments on commit 1c7d36c

Please sign in to comment.