Skip to content

Commit bae633a

Browse files
committed
Shared: Make 'erasedHaveIntersection' more identical to the Java version.
1 parent 9deeb67 commit bae633a

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

shared/typeflow/codeql/typeflow/internal/TypeFlowImpl.qll

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ module TypeFlow<LocationSig Location, TypeFlowInput<Location> I> {
301301
not irrelevantBound(n, t)
302302
}
303303

304-
/**
304+
/**
305305
* Holds if the runtime type of `n` is bounded by `t` and if this bound is
306306
* likely to be better than the static type of `n`. The flag `exact` indicates
307307
* whether `t` is an exact bound or merely an upper bound.
@@ -389,14 +389,24 @@ module TypeFlow<LocationSig Location, TypeFlowInput<Location> I> {
389389
)
390390
}
391391

392+
/** Holds if this type is the same as its source declaration. */
393+
private predicate isSourceDeclaration(Type t) { getSourceDeclaration(t) = t }
394+
395+
final private class FinalType = Type;
396+
397+
/** A type that is the same as its source declaration. */
398+
private class SrcType extends FinalType {
399+
SrcType() { isSourceDeclaration(this) }
400+
}
401+
392402
/**
393403
* Holds if there is a common (reflexive, transitive) subtype of the erased
394404
* types `t1` and `t2`.
395405
*/
406+
pragma[nomagic]
396407
private predicate erasedHaveIntersection(Type t1, Type t2) {
397-
exists(Type commonSub | commonSub = getSourceDeclaration(commonSub) |
398-
getASourceSupertype*(commonSub) = t1 and
399-
getASourceSupertype*(commonSub) = t2
408+
exists(SrcType commonSub |
409+
getASourceSupertype*(commonSub) = t1 and getASourceSupertype*(commonSub) = t2
400410
) and
401411
t1 = getErasure(_) and
402412
t2 = getErasure(_)

0 commit comments

Comments
 (0)