@@ -59,16 +59,25 @@ private class MethodCallSig extends CallSignatureType {
5959 string getName ( ) { result = name }
6060}
6161
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+
6273/**
6374 * Holds if the two call signatures could be overloads of each other and have the same parameter types.
6475 */
6576predicate 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
7080 // purposely not looking at number of type arguments.
71- method .getKind ( ) = other .getKind ( ) and
7281 forall ( int i | i in [ 0 .. - 1 + method .getNumParameter ( ) ] |
7382 method .getParameter ( i ) = other .getParameter ( i ) // This is sometimes imprecise, so it is still a good idea to compare type annotations.
7483 ) and
@@ -88,18 +97,24 @@ int getOverloadIndex(MethodSignature sig) {
8897 sig .getDeclaringType ( ) .getMethodOverload ( sig .getName ( ) , result ) = sig
8998}
9099
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+
91110/**
92111 * Holds if the two method signatures are overloads of each other and have the same parameter types.
93112 */
94113predicate 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
103118 // same this parameter (if exists)
104119 (
105120 not exists ( method .getBody ( ) .getThisTypeAnnotation ( ) ) and
0 commit comments