Skip to content

Unified: Extract Swift attributed types - #22813

Open
paldepind wants to merge 3 commits into
mainfrom
unified/swift-extract-attributed-types
Open

paldepind wants to merge 3 commits into
mainfrom
unified/swift-extract-attributed-types

Conversation

@paldepind

@paldepind paldepind commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Attributed types such as inout D, sending T and @escaping () -> T are currently unsupported.

This PR adds a new modified_type_expr node and maps attributedType to it.

Some thoughts for future changes:

  • Attributes like @escaping are currently just mapped to modifiers (which is just a token). However, they can takes arguments, so maybe we want to add a new attribute/annotation AST node to represent these better.
  • We should implement type inference support for the new node. I'll do that in a follow up PR.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
final override string getAPrimaryQlClass() { result = "ModifiedTypeExpr" }

/** Gets the node corresponding to the field `modifier`. */
final F::Modifier getModifier(int i) { unified_modified_type_expr_modifier(this, i, result) }
Preserve the base type of attributed types (`inout T`, `sending T`,
`@escaping () -> T`) and keep their specifiers and attributes as modifiers.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@paldepind
paldepind force-pushed the unified/swift-extract-attributed-types branch from d8fb01b to 4fcecf2 Compare October 13, 2026 09:47
@paldepind
paldepind marked this pull request as ready for review October 13, 2026 09:55
@paldepind
paldepind requested review from a team as code owners October 13, 2026 09:55
Copilot AI balanced review requested due to automatic review settings October 13, 2026 09:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The schema, mapping, generated artifacts, and representative corpus coverage are consistent with the stated scope.

0 open findings

What changed in this PR

Adds structural extraction support for Swift attributed types while preserving modifiers and underlying type context.

Changes:

  • Introduces ModifiedTypeExpr in the unified AST schema.
  • Maps Swift type specifiers and attributes to modifiers.
  • Adds and updates extractor and control-flow expectations.
File Description
unified/​extractor/​ast_types.yml Defines modified type expressions.
unified/​extractor/​src/​languages/​swift/​swift.rs Maps Swift attributed types.
unified/​ql/​lib/​unified.dbscheme Regenerates database schema.
unified/​ql/​lib/​codeql/​unified/​internal/​Ast.qll Regenerates QL AST classes.
unified/​ql/​lib/​codeql/​unified/​internal/​ExprPositions.qll Marks wrapped types as type-context expressions.
unified/​extractor/​tests/​corpus/​swift/​functions/​attributed-parameter-types.swift Tests attributed parameters.
unified/​extractor/​tests/​corpus/​swift/​functions/​attributed-parameter-types.output Records generated attributed-parameter AST.
unified/​extractor/​tests/​corpus/​swift/​functions/​function-with-inout-parameter.output Updates inout extraction expectation.
unified/​extractor/​tests/​corpus/​swift/​types/​function-type-with-inout-parameter.swift Tests inout in function types.
unified/​extractor/​tests/​corpus/​swift/​types/​function-type-with-inout-parameter.output Records generated function-type AST.
unified/​extractor/​tests/​corpus/​swift/​types/​function-type-with-sendable-attribute.output Updates @Sendable extraction.
unified/​extractor/​tests/​corpus/​swift/​types/​function-type-with-convention-attribute.output Updates attributed function-type extraction.
unified/​ql/​test/​library-tests/​controlflow/​cfg.swift Annotates newly exposed type syntax.
unified/​ql/​test/​library-tests/​controlflow/​cfg.expected Updates generated CFG expectations.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@paldepind paldepind added the no-change-note-required This PR does not need a change note label Oct 13, 2026

This branch has not been deployed

No deployments
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 Unified

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants