Skip to content

Unified: Add folder-based fallback for static name resolution - #22370

Draft
asgerf wants to merge 5 commits into
github:mainfrom
asgerf:unified/folder-fallback
Draft

Unified: Add folder-based fallback for static name resolution#22370
asgerf wants to merge 5 commits into
github:mainfrom
asgerf:unified/folder-fallback

Conversation

@asgerf

@asgerf asgerf commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Static name resolution relies on Package.swift manifests to indicate how files are linked up. In the absence of a known manifest file, we had no way of linking up names across files.

This PR adds a generic fallback mechanism for files that are not covered by a known manifest. An unqualified name X, appearing in a file without a known manifest, may now resolve to any (exported) top-level declaration X. If multiple such declarations exist, we prioritise the one "closest" in the file hierarchy, meaning the one with the lowest common ancestor in the folder tree.

If two definitions are tied for being closest, none is resolved as the target. Some more real-world examples of this would help motivate what to do here.

We can't use DCA for evals right now, but on one large repository I tested on, the number of jump-to-def targets goes from 264k -> 344k.

asgerf added 5 commits August 18, 2026 10:10
The spurious result is offered by the folder-based heuristic, but would have been blocked by proper shadowing support.
Inheritance and access to nested classes is one of the reasons not to apply the heuristic as a "fixup" after the recursive layer, because when a base class is resolved through the folder heuristic, access to nested members still need to be resolved through the standard logic.
@asgerf
asgerf force-pushed the unified/folder-fallback branch from 01d2ec1 to 60dd3ba Compare August 18, 2026 08:10
@asgerf asgerf added the no-change-note-required This PR does not need a change note label Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-change-note-required This PR does not need a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant