Go: Improve two class names and add some helper predicates#19677
Merged
owen-mc merged 6 commits intogithub:mainfrom Jun 25, 2025
Merged
Go: Improve two class names and add some helper predicates#19677owen-mc merged 6 commits intogithub:mainfrom
owen-mc merged 6 commits intogithub:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR renames two core QL classes to better reflect their roles, deprecates the old names, and adds helper methods and predicates to navigate between declarations and the entities they declare.
- Rename
DeclaredType→DeclaredTypeEntityandBuiltinType→BuiltinTypeEntity, with deprecated aliases for backward compatibility. - Introduce new methods on
TypeSpec(getDeclaredType,getRhsType) and onFieldDecl(getField,isEmbedded), plus updated docs. - Update library tests to exercise the new helpers and adjust expected outputs accordingly.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| go/ql/test/library-tests/semmle/go/Types/FieldDecl.ql | Added test predicates for getField and isEmbedded. |
| go/ql/test/library-tests/semmle/go/Types/FieldDecl.expected | Updated expected output to include the new field declaration tests. |
| go/ql/test/library-tests/semmle/go/Decl/TypeSpec.ql | Expanded select to output getDeclaredType and getRhsType. |
| go/ql/test/library-tests/semmle/go/Decl/TypeSpec.expected | Adjusted expected columns to match the expanded select clause. |
| go/ql/lib/semmle/go/Scopes.qll | Renamed DeclaredType/BuiltinType classes to *Entity versions and added deprecated aliases; updated builtin type generators. |
| go/ql/lib/semmle/go/Decls.qll | Added getDeclaredType, getRhsType, getField, isEmbedded methods and updated related documentation. |
| go/ql/lib/change-notes/2025-06-05-deprecate-DeclaredType-BuiltinType.md | Documented deprecation of the old class names. |
smowton
approved these changes
Jun 25, 2025
Contributor
smowton
left a comment
There was a problem hiding this comment.
Looks plausible. Suggest a quick DCA to verify this doesn't make any bad optimisation nudges re: some quite fundamental classes.
Contributor
Author
|
DCA looks fine. |
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.
This pull request introduces deprecations and enhancements to the Go QL library, focusing on improving the link between declarations and the things that have been declared. Key changes include the deprecation of
BuiltinTypeandDeclaredTypein favor of new replacements, the addition of new methods for going from type and field declarations to the type and fields that have been declared, and updates to tests.