Skip to content

Swift: Expose the declared interface type of a type decl#21831

Open
jketema wants to merge 2 commits into
github:mainfrom
jketema:jketema/swift-declared-interface-type
Open

Swift: Expose the declared interface type of a type decl#21831
jketema wants to merge 2 commits into
github:mainfrom
jketema:jketema/swift-declared-interface-type

Conversation

@jketema
Copy link
Copy Markdown
Contributor

@jketema jketema commented May 11, 2026

No description provided.

@github-actions github-actions Bot added the Swift label May 11, 2026
@jketema jketema marked this pull request as ready for review May 11, 2026 15:24
@jketema jketema requested a review from a team as a code owner May 11, 2026 15:24
Copilot AI review requested due to automatic review settings May 11, 2026 15:24
@jketema jketema requested a review from a team as a code owner May 11, 2026 15:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the Swift extractor schema to expose a type declaration’s declared interface type (as distinct from the existing ValueDecl.getInterfaceType(), which typically returns the metatype like Foo.Type). This enables downstream Swift QL libraries and queries to reason about the syntactic/declared type shape for TypeDecl entities.

Changes:

  • Add a declared_interface_type column to the Swift DB scheme type_decls relation and populate it in the extractor.
  • Expose the new data via TypeDecl.getDeclaredInterfaceType() in the Swift QL libraries.
  • Regenerate extractor tests/expected outputs, add an upgrade step, and add a change note.
Show a summary per file
File Description
swift/schema.py Adds declared_interface_type to the TypeDecl schema model.
swift/extractor/translators/DeclTranslator.cpp Populates declared_interface_type from swift::TypeDecl::getDeclaredInterfaceType() during extraction.
swift/ql/lib/swift.dbscheme Extends type_decls relation with declared_interface_type: @type_or_none.
swift/ql/lib/codeql/swift/generated/Raw.qll Regenerated: adjusts type_decls arity usage and exposes getDeclaredInterfaceType() at the raw layer.
swift/ql/lib/codeql/swift/generated/decl/TypeDecl.qll Regenerated: adds getImmediateDeclaredInterfaceType() / getDeclaredInterfaceType() in the typed API.
swift/ql/lib/upgrades/5738be6bb04742c424efdbf9f4de11f0b10fa37d/upgrade.ql Adds an upgrade step for the new type_decls column (with unspecified-element handling).
swift/ql/lib/upgrades/5738be6bb04742c424efdbf9f4de11f0b10fa37d/upgrade.properties Registers the Swift DB upgrade as backwards-compatible.
swift/downgrades/1bb163e31d206f30146738adcd93def10fdabefa/upgrade.properties Adds downgrade mapping to drop/reorder the new type_decls column.
swift/downgrades/1bb163e31d206f30146738adcd93def10fdabefa/swift.dbscheme Generated downgrade dbscheme snapshot for the target version.
swift/downgrades/1bb163e31d206f30146738adcd93def10fdabefa/old.dbscheme Generated “old” dbscheme snapshot used for downgrade validation.
swift/ql/test/extractor-tests/generated/decl/OpaqueTypeDecl/OpaqueTypeDecl.ql Regenerated extractor test to exercise getDeclaredInterfaceType().
swift/ql/test/extractor-tests/generated/decl/OpaqueTypeDecl/OpaqueTypeDecl.expected Updates expected output to include declared interface type values for opaque types.
swift/ql/test/extractor-tests/generated/decl/ModuleDecl/ModuleDecl.ql Regenerated extractor test to include getDeclaredInterfaceType().
swift/ql/test/extractor-tests/generated/decl/ModuleDecl/ModuleDecl.expected Updates expected output to include declared interface type for modules.
swift/ql/test/extractor-tests/generated/decl/EnumDecl/EnumDecl.ql Regenerated extractor test to include getDeclaredInterfaceType().
swift/ql/test/extractor-tests/generated/decl/EnumDecl/EnumDecl.expected Updates expected output to include declared interface type for enums.
swift/ql/test/extractor-tests/generated/decl/ClassDecl/ClassDecl.ql Regenerated extractor test to include getDeclaredInterfaceType().
swift/ql/test/extractor-tests/generated/decl/ClassDecl/ClassDecl.expected Updates expected output to include declared interface type for classes.
swift/ql/test/extractor-tests/generated/decl/AssociatedTypeDecl/AssociatedTypeDecl.ql Regenerated extractor test to include getDeclaredInterfaceType().
swift/ql/test/extractor-tests/generated/decl/AssociatedTypeDecl/AssociatedTypeDecl.expected Updates expected output to include declared interface type for associated types.
swift/ql/lib/change-notes/2026-05-11-declared-interface-type.md Adds a change note documenting the new TypeDecl.getDeclaredInterfaceType API.
swift/ql/.generated.list Updates generated-file hashes for regenerated Swift QL/test artifacts.

Copilot's findings

  • Files reviewed: 12/24 changed files
  • Comments generated: 0

Copy link
Copy Markdown
Contributor

@hvitved hvitved left a comment

Choose a reason for hiding this comment

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

Looks plausible to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants