Skip to content

Commit 5a65282

Browse files
authored
Merge pull request #21429 from github/tausbn/fix-bad-join-in-method-call-order
Python: Fix bad join in method call order computation
2 parents 79499c2 + c5360ba commit 5a65282

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

python/ql/src/Classes/CallsToInitDel/MethodCallOrder.qll

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,18 +152,23 @@ predicate missingCallToSuperclassMethod(Class base, Function shouldCall, string
152152
*/
153153
predicate missingCallToSuperclassMethodRestricted(Class base, Function shouldCall, string name) {
154154
missingCallToSuperclassMethod(base, shouldCall, name) and
155-
not exists(Class superBase |
156-
// Alert only on the highest base class that has the issue
157-
superBase = getADirectSuperclass+(base) and
158-
missingCallToSuperclassMethod(superBase, shouldCall, name)
159-
) and
155+
not superclassAlsoMissesCall(base, shouldCall, name) and
160156
not exists(Function subShouldCall |
161157
// Mention in the alert only the lowest method we're missing the call to
162158
subShouldCall.getScope() = getADirectSubclass+(shouldCall.getScope()) and
163159
missingCallToSuperclassMethod(base, subShouldCall, name)
164160
)
165161
}
166162

163+
/**
164+
* Holds if a strict superclass of `base` is also missing a call to `shouldCall` named `name`,
165+
* indicating that `base` is not the highest class in the hierarchy with this issue.
166+
*/
167+
pragma[nomagic]
168+
private predicate superclassAlsoMissesCall(Class base, Function shouldCall, string name) {
169+
missingCallToSuperclassMethod(getADirectSuperclass+(base), shouldCall, name)
170+
}
171+
167172
/**
168173
* If `base` contains a `super()` call, gets a method in the inheritance hierarchy of `name` in the MRO of `base`
169174
* that does not contain a `super()` call, but would call `shouldCall` if it did, which does not otherwise get called

0 commit comments

Comments
 (0)