Skip to content

Commit 304e292

Browse files
committed
Java: Fix RefType.getAStrictAncestor() in the presence of type hierarchy cycles
1 parent 7c5a490 commit 304e292

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

java/ql/lib/semmle/code/java/Type.qll

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,12 @@ class RefType extends Type, Annotatable, Modifiable, @reftype {
413413
/** Gets a direct or indirect supertype of this type, including itself. */
414414
RefType getAnAncestor() { hasDescendant(result, this) }
415415

416-
/** Gets a direct or indirect supertype of this type, not including itself. */
417-
RefType getAStrictAncestor() { result = this.getAnAncestor() and result != this }
416+
/**
417+
* Gets a direct or indirect supertype of this type.
418+
* This does not including itself, unless this type is part of a cycle
419+
* in the type hierarchy.
420+
*/
421+
RefType getAStrictAncestor() { result = this.getASupertype().getAnAncestor() }
418422

419423
/**
420424
* Gets the source declaration of a direct supertype of this type, excluding itself.

0 commit comments

Comments
 (0)