Unified: Add folder-based fallback for static name resolution - #22370
Draft
asgerf wants to merge 5 commits into
Draft
Unified: Add folder-based fallback for static name resolution#22370asgerf wants to merge 5 commits into
asgerf wants to merge 5 commits into
Conversation
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
force-pushed
the
unified/folder-fallback
branch
from
August 18, 2026 08:10
01d2ec1 to
60dd3ba
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Static name resolution relies on
Package.swiftmanifests 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 declarationX. 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.