@@ -59,16 +59,25 @@ private class MethodCallSig extends CallSignatureType {
59
59
string getName ( ) { result = name }
60
60
}
61
61
62
+ pragma [ noinline]
63
+ private MethodCallSig getMethodCallSigWithFingerprint (
64
+ string name , int optionalParams , int numParams , int requiredParms , SignatureKind kind
65
+ ) {
66
+ name = result .getName ( ) and
67
+ optionalParams = result .getNumOptionalParameter ( ) and
68
+ numParams = result .getNumParameter ( ) and
69
+ requiredParms = result .getNumRequiredParameter ( ) and
70
+ kind = result .getKind ( )
71
+ }
72
+
62
73
/**
63
74
* Holds if the two call signatures could be overloads of each other and have the same parameter types.
64
75
*/
65
76
predicate matchingCallSignature ( MethodCallSig method , MethodCallSig other ) {
66
- method .getName ( ) = other .getName ( ) and
67
- method .getNumOptionalParameter ( ) = other .getNumOptionalParameter ( ) and
68
- method .getNumParameter ( ) = other .getNumParameter ( ) and
69
- method .getNumRequiredParameter ( ) = other .getNumRequiredParameter ( ) and
77
+ other =
78
+ getMethodCallSigWithFingerprint ( method .getName ( ) , method .getNumOptionalParameter ( ) ,
79
+ method .getNumParameter ( ) , method .getNumRequiredParameter ( ) , method .getKind ( ) ) and
70
80
// purposely not looking at number of type arguments.
71
- method .getKind ( ) = other .getKind ( ) and
72
81
forall ( int i | i in [ 0 .. - 1 + method .getNumParameter ( ) ] |
73
82
method .getParameter ( i ) = other .getParameter ( i ) // This is sometimes imprecise, so it is still a good idea to compare type annotations.
74
83
) and
@@ -88,18 +97,24 @@ int getOverloadIndex(MethodSignature sig) {
88
97
sig .getDeclaringType ( ) .getMethodOverload ( sig .getName ( ) , result ) = sig
89
98
}
90
99
100
+ pragma [ noinline]
101
+ private MethodSignature getMethodSignatureWithFingerprint (
102
+ ClassOrInterface declaringType , string name , int numParameters , string kind
103
+ ) {
104
+ result .getDeclaringType ( ) = declaringType and
105
+ result .getName ( ) = name and
106
+ getKind ( result ) = kind and
107
+ result .getBody ( ) .getNumParameter ( ) = numParameters
108
+ }
109
+
91
110
/**
92
111
* Holds if the two method signatures are overloads of each other and have the same parameter types.
93
112
*/
94
113
predicate signaturesMatch ( MethodSignature method , MethodSignature other ) {
95
- // declared in the same interface/class.
96
- method .getDeclaringType ( ) = other .getDeclaringType ( ) and
97
- // same static modifier.
98
- getKind ( method ) = getKind ( other ) and
99
- // same name.
100
- method .getName ( ) = other .getName ( ) and
101
- // same number of parameters.
102
- method .getBody ( ) .getNumParameter ( ) = other .getBody ( ) .getNumParameter ( ) and
114
+ // the intial search for another overload in a single call for better join-order.
115
+ other =
116
+ getMethodSignatureWithFingerprint ( method .getDeclaringType ( ) , method .getName ( ) ,
117
+ method .getBody ( ) .getNumParameter ( ) , getKind ( method ) ) and
103
118
// same this parameter (if exists)
104
119
(
105
120
not exists ( method .getBody ( ) .getThisTypeAnnotation ( ) ) and
0 commit comments