Files
Artem Chikin 690dbc530c [Source Warning Control] Avoid duplicate canImport diagnostics from secondary #if walks
`#if canImport(...)` conditions are evaluated by the parser's primary
`EvaluateIfConditionRequest`, which emits `cannot_find_module_version` and
records the result in `CanImportModuleVersions`. Several later analyses re-walk
the same directives and, before this change, routed through that same emitting
`canImportModule` path, duplicating the diagnostic: the
`ExportedSourceFile.configuredRegions` region-tree rebuild that backs
diagnostic-group control (which could also recurse indefinitely), and the
`VarDeclUsageChecker` inactive-code scans behind unused-variable diagnostics.

Introduce a `CanImportMode` on `CompilerBuildConfiguration` distinguishing the
canonical, diagnostic-emitting `.driving` query from a side-effect-free
`.analyzing` re-derivation. `.analyzing` routes to the new
`BridgedASTContext.testCanImport` -> `ASTContext::testImportModule` bridge,
which answers from the module loaders without emitting diagnostics or populating
`CanImportModuleVersions`; `.driving` keeps the existing `canImport` behavior.
The mode defaults to `.analyzing`, so only the canonical site
`evaluatePoundIfCondition` drives, while every secondary walk re-derives `#if`
activity without repeating the diagnostic.
2026-06-05 10:29:15 +01:00
..