Swift: Expose the declared interface type of a type decl#21831
Open
jketema wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
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_typecolumn to the Swift DB schemetype_declsrelation 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
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.
No description provided.