Skip to content

Commit 3b704ae

Browse files
asgerfCopilot
andcommitted
Unified: Resolve setter call targets via the invocation lookup
Reuse lookupInstanceMember and static name binding in resolveSetterCallTarget, rather than duplicating the namespace lookup. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 9f11b76 commit 3b704ae

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

‎unified/ql/lib/codeql/unified/internal/typeinference/TypeInference.qll‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,15 @@ module Input3 implements InputSig3 {
577577
exists(c)
578578
}
579579

580+
/**
581+
* Gets the setter method invoked when this call appears as an assignment target, or is
582+
* otherwise updated in place.
583+
*/
584+
Callable getSetterTarget() {
585+
result = [lookupInstanceMember(this.getCallee()), this.getTargetViaStaticNameBinding()] and
586+
result.asCallable() instanceof SetterMethodDeclaration
587+
}
588+
580589
Callable getATargetForTypeQualifierMatching() { result = this.getTargetViaStaticNameBinding() }
581590
}
582591

@@ -966,16 +975,7 @@ Callable resolveCallTarget(CallExpr ce) {
966975
cached
967976
SetterMethodDeclaration resolveSetterCallTarget(CallExpr ce) {
968977
CachedStage::ref() and
969-
exists(MemberAccessExpr callee, ClassLikeDeclaration cls, NamespaceNode ns |
970-
callee = ce.getCallee() and
971-
ns.getMember(callee.getMemberName()).isIdentifier(result.getNameNode())
972-
|
973-
cls = inferType(callee.getBase()).asClass() and
974-
ns.isInstanceMemberNamespace(cls)
975-
or
976-
cls = callee.getBase().(TypeMention).getType().asClass() and
977-
ns.isStaticMemberNamespace(cls)
978-
)
978+
result = ce.(Input3::Invocation).getSetterTarget().asCallable()
979979
}
980980

981981
private predicate typeTestAstNodeRepr(AstNode n, string repr) {

0 commit comments

Comments
 (0)