Ruby: fix getAssociatedMethod predicate to include class methods

This commit is contained in:
Alex Ford
2022-05-05 18:09:15 +01:00
parent 1e3ab52e1f
commit 961f867bed
2 changed files with 9 additions and 8 deletions

View File

@@ -238,13 +238,14 @@ module Rbi {
/**
* Gets the method whose type signature is defined by this call.
*/
Method getAssociatedMethod() {
ExprCfgNode getAssociatedMethod() {
result =
min(ExprCfgNode methodCfgNode, int i |
methodSignatureSuccessorNodeRanked(this, methodCfgNode, i)
min(ExprCfgNode m, int i |
methodSignatureSuccessorNodeRanked(this, m, i) and
m.getExpr() instanceof MethodBase
|
methodCfgNode order by i
).getExpr()
m order by i
)
}
/**
@@ -404,13 +405,13 @@ module Rbi {
private SignatureCall getOuterMethodSignatureCall() { this = result.getAParameterType() }
private Method getAssociatedMethod() {
private ExprCfgNode getAssociatedMethod() {
result = this.getOuterMethodSignatureCall().(MethodSignatureCall).getAssociatedMethod()
}
/** Gets the parameter to which this type applies. */
NamedParameter getParameter() {
result = this.getAssociatedMethod().getAParameter() and
result = this.getAssociatedMethod().getExpr().(MethodBase).getAParameter() and
result.getName() = this.getKey().getConstantValue().getStringlikeValue()
}
}

View File

@@ -42,7 +42,7 @@ query predicate procParameterTypes(
pc = prtc.getProcCall()
}
query predicate sigMethods(MethodSignatureCall sig, Method m) { m = sig.getAssociatedMethod() }
query predicate sigMethods(MethodSignatureCall sig, ExprCfgNode m) { m = sig.getAssociatedMethod() }
query predicate sigAttrReaders(MethodSignatureCall sig, ExprNodes::MethodCallCfgNode attr_reader) {
attr_reader = sig.getAssociatedAttrReaderCall()