Skip to content

feat: add getASupertype() predicate in ValueOrRefType. #20008

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Hug0Vincent
Copy link

Add the getASupertype() predicate in ValueOrRefType like in Java: https://codeql.github.com/codeql-standard-libraries/java/semmle/code/java/Type.qll/predicate.Type$RefType$getASupertype.0.html

It's my first PR for CodeQL let me know if I did something wrong :)

Add the getASupertype() predicate in ValueOrRefType.
@Hug0Vincent Hug0Vincent requested a review from a team as a code owner July 10, 2025 00:20
@github-actions github-actions bot added the C# label Jul 10, 2025
Create 2025-06-10-getasupertype.md
@michaelnebel
Copy link
Contributor

DCA looks good.

Copy link
Contributor

@michaelnebel michaelnebel left a comment

Choose a reason for hiding this comment

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

Thank you very much for doing this! 😄

@@ -138,6 +138,9 @@ class ValueOrRefType extends Type, Attributable, @value_or_ref_type {
/** Gets an immediate subtype of this type, if any. */
ValueOrRefType getASubType() { result.getABaseType() = this }

/** Gets an immediate supertype of this type, if any. */
ValueOrRefType getASupertype() { this.getABaseType() = result }
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like the capitalisation between Java and C# is a bit different - so for C# we probably need to name this predicate getASuperType to streamline it with the other predicate names.

---
category: feature
---
* Added a new predicate, `getASupertype()`, to get a direct supertype of this type.
Copy link
Contributor

@michaelnebel michaelnebel Jul 15, 2025

Choose a reason for hiding this comment

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

Need to adjust the name - see comment above.

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.

2 participants