Skip to content

SwiftLexicalLookup: Add Syntax Type Helpers for Member-Type Lookup#3378

Open
filip-sakel wants to merge 5 commits into
swiftlang:mainfrom
filip-sakel:qualified-type-lookup
Open

SwiftLexicalLookup: Add Syntax Type Helpers for Member-Type Lookup#3378
filip-sakel wants to merge 5 commits into
swiftlang:mainfrom
filip-sakel:qualified-type-lookup

Conversation

@filip-sakel

@filip-sakel filip-sakel commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

A follow-up to #3346 for the qualified name-lookup GSoC 2026 project.

Changes

  1. Add NominalTypeDeclSyntax (struct, enum, class, actor, or protocol)
  2. Add TypeDeclSyntax (a nominal type declaration, type alias, or associated/generic type)
    • Unqualified type lookup will return TypeDeclSyntax nodes
  3. Add TypeLikeSyntax (a TypeSyntax or NominalTypeDeclSyntax)
    • Helps us track where a type-resolution request originated
    • For instance:
      struct A {
         func f(b: B) {} // <- Look up `B` here
      }
      extension A { struct B {} }
      When looking up B, we first look for member types of A, which means we generate a request to fully resolve A. Note that no type syntax references A; instead, we resolve A because the syntax is nested in a nominal-type declaration. TypeLikeSyntax allows us to represent struct A as the syntax initiating the request.
  4. Rename old NominalTypeDeclSyntax->NominalTypeDeclScopeSyntax.
    • This type is used internally to implement unqualified lookup
    • Protocols now also conform to this type.

@filip-sakel

Copy link
Copy Markdown
Contributor Author

@swift-ci please test

1 similar comment
@filip-sakel

Copy link
Copy Markdown
Contributor Author

@swift-ci please test

@filip-sakel

Copy link
Copy Markdown
Contributor Author

My initial attempt converted the old NominalTypeDeclSyntax to NonProtocolNominalTypeDeclSyntax, which was quite confusing. Instead, in the last two commits, I converted the old type to NominalTypeDeclScopeSyntax to better convey that the protocol is used to implement scope lookup.

@filip-sakel

Copy link
Copy Markdown
Contributor Author

@swift-ci please test

1 similar comment
@filip-sakel

Copy link
Copy Markdown
Contributor Author

@swift-ci please test

@filip-sakel filip-sakel force-pushed the qualified-type-lookup branch from 3e31a7f to 58b9665 Compare July 14, 2026 21:10
@xedin

xedin commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

@swift-ci please test

@xedin

xedin commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

@swift-ci please test Windows platform

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