Skip to content

[SwiftLexicalLookup] Implement the first step of type resolution - #3399

Merged
xedin merged 4 commits into
swiftlang:mainfrom
filip-sakel:partial-type-resolution
Aug 12, 2026
Merged

[SwiftLexicalLookup] Implement the first step of type resolution#3399
xedin merged 4 commits into
swiftlang:mainfrom
filip-sakel:partial-type-resolution

Conversation

@filip-sakel

@filip-sakel filip-sakel commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

A follow-up to #3390 for the qualified name-lookup GSoC 2026 project. Introduces (partial) type resolution.

Changes

Partial Type Resolution

"Partial" type resolution in this PR takes type syntax and basically resolves to a non-nominal type (Any, tuple, function), a type identifier, a member type, or a composition. The future type-resolver machinery will then do one of the following: return the non-nominal type, perform unqualified lookup for identifier types, qualified lookup for member types, or resolve each type in a composition. I call this "partial" resolution because compositions and member types still have type syntax as their children.

Attached

The Attached<Node> type describes a syntax node attached to a SourceFileSyntax root (juxtaposed with SyntaxProtocol/detached). Ensuring that a given syntax is part of a file is very useful for later steps, where we want to find the module in which a type is declared. In addition, 'casting' nodes to Attached` makes us more careful about only admitting known/registered files to the type graph.

Notes:

  1. Attached doesn't store SourceFileRoot as a property since it already contains root; storing an additional property would just pollute the cache
  2. Attached doesn't conform to SyntaxProtocol because its initializer takes in the type's Node generic parameter and not an arbitrary some SyntaxProtocol. However, we provide similar casting methods and convenience properties, so users of Attached get a similar interface.

Open Questions

  1. How to handle the shadowing rules of .self?

@filip-sakel
filip-sakel force-pushed the partial-type-resolution branch from 58d8c92 to 7da1d64 Compare August 7, 2026 15:23
…ce from TypeLikeSyntaxProtocol to match other syntax protocols.
@filip-sakel
filip-sakel force-pushed the partial-type-resolution branch from 7da1d64 to d78f792 Compare August 7, 2026 15:29
@filip-sakel

Copy link
Copy Markdown
Contributor Author

I trimmed down some changes to make the PR easier to review. I forced pushed to maintain a clean history, since this was still a draft PR.

@filip-sakel
filip-sakel marked this pull request as ready for review August 7, 2026 17:13
@filip-sakel

Copy link
Copy Markdown
Contributor Author

@swift-ci please test Linux Platform

@filip-sakel

Copy link
Copy Markdown
Contributor Author

@swift-ci please test Linux platform

@filip-sakel

Copy link
Copy Markdown
Contributor Author

@swift-ci please test

@filip-sakel

Copy link
Copy Markdown
Contributor Author

@swift-ci please test

@filip-sakel

Copy link
Copy Markdown
Contributor Author

@swift-ci please test Windows platform

@filip-sakel

Copy link
Copy Markdown
Contributor Author

@swift-ci please test Wasm platform

@filip-sakel

Copy link
Copy Markdown
Contributor Author

@swift-ci please test Wasm

@xedin
xedin merged commit 7dee7d6 into swiftlang:main Aug 12, 2026
51 of 81 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants