diff --git a/csharp/ql/lib/change-notes/2025-06-10-getasupertype.md b/csharp/ql/lib/change-notes/2025-06-10-getasupertype.md new file mode 100644 index 000000000000..8f91b2d3cc5b --- /dev/null +++ b/csharp/ql/lib/change-notes/2025-06-10-getasupertype.md @@ -0,0 +1,4 @@ +--- +category: feature +--- +* Added a new predicate, `getASupertype()`, to get a direct supertype of this type. diff --git a/csharp/ql/lib/semmle/code/csharp/Type.qll b/csharp/ql/lib/semmle/code/csharp/Type.qll index 9283bb3002a1..3693e8977d89 100644 --- a/csharp/ql/lib/semmle/code/csharp/Type.qll +++ b/csharp/ql/lib/semmle/code/csharp/Type.qll @@ -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 } + /** Gets a member of this type, if any. */ Member getAMember() { result.getDeclaringType() = this }