-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Go: Improve two class names and add some helper predicates #19677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Go: Improve two class names and add some helper predicates #19677
Conversation
There was a problem hiding this 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 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
→DeclaredTypeEntity
andBuiltinType
→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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks plausible. Suggest a quick DCA to verify this doesn't make any bad optimisation nudges re: some quite fundamental classes.
DCA looks fine. |
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
BuiltinType
andDeclaredType
in 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.