@@ -51,6 +51,12 @@ public void getConstructorRefinements(CtConstructor<?> c) throws ParsingExceptio
5151 f .setType (c .getType ());
5252 handleFunctionRefinements (f , c , c .getParameters ());
5353 f .setRefReturn (new Predicate ());
54+ CtTypeReference <?> declaring = c .getDeclaringType () != null ? c .getDeclaringType ().getReference () : null ;
55+ if (declaring != null ) {
56+ f .setSignature (String .format ("%s.%s" , declaring .getQualifiedName (), c .getSignature ()));
57+ } else {
58+ f .setSignature (c .getSignature ());
59+ }
5460 if (c .getParent () instanceof CtClass ) {
5561 CtClass <?> klass = (CtClass <?>) c .getParent ();
5662 f .setClass (klass .getQualifiedName ());
@@ -89,6 +95,11 @@ public <R> void getMethodRefinements(CtMethod<R> method) throws ParsingException
8995 CtInterface <?> inter = (CtInterface <?>) method .getParent ();
9096 f .setClass (inter .getQualifiedName ());
9197 }
98+ String owner = f .getTargetClass ();
99+ if (owner != null )
100+ f .setSignature (String .format ("%s.%s" , owner , method .getSignature ()));
101+ else
102+ f .setSignature (method .getSignature ());
92103 rtc .getContext ().addFunctionToContext (f );
93104
94105 auxGetMethodRefinements (method , f );
@@ -113,6 +124,7 @@ public <R> void getMethodRefinements(CtMethod<R> method, String prefix) throws P
113124 f .setType (method .getType ());
114125 f .setRefReturn (new Predicate ());
115126 f .setClass (prefix );
127+ f .setSignature (String .format ("%s.%s" , prefix , method .getSignature ()));
116128 rtc .getContext ().addFunctionToContext (f );
117129 auxGetMethodRefinements (method , f );
118130
@@ -251,7 +263,7 @@ public <R> void getInvocationRefinements(CtInvocation<R> invocation) {
251263 public RefinedFunction getRefinementFunction (String methodName , String className , int size ) {
252264 RefinedFunction f = rtc .getContext ().getFunction (methodName , className , size );
253265 if (f == null )
254- f = rtc .getContext ().getFunction (String .format ("%s.%s" , className , methodName ), methodName , size );
266+ f = rtc .getContext ().getFunction (String .format ("%s.%s" , className , methodName ), className , size );
255267 return f ;
256268 }
257269
@@ -266,12 +278,26 @@ private void searchMethodInLibrary(CtExecutableReference<?> ctr, CtInvocation<?>
266278
267279 String name = ctr .getSimpleName (); // missing
268280 int argSize = invocation .getArguments ().size ();
281+ String qualifiedSignature = null ;
282+ if (ctype != null ) {
283+ qualifiedSignature = String .format ("%s.%s" , ctype , ctr .getSignature ());
284+ if (rtc .getContext ().getFunction (qualifiedSignature , ctype , argSize ) != null ) {
285+ checkInvocationRefinements (invocation , invocation .getArguments (), invocation .getTarget (),
286+ qualifiedSignature , ctype );
287+ return ;
288+ }
289+ }
290+ String signature = ctr .getSignature ();
291+ if (rtc .getContext ().getFunction (signature , ctype , argSize ) != null ) {
292+ checkInvocationRefinements (invocation , invocation .getArguments (), invocation .getTarget (), signature , ctype );
293+ return ;
294+ }
269295 if (rtc .getContext ().getFunction (name , ctype , argSize ) != null ) { // inside rtc.context
270296 checkInvocationRefinements (invocation , invocation .getArguments (), invocation .getTarget (), name , ctype );
271297 return ;
272- } else {
273- String prefix = ctype ;
274- String completeName = String .format ("%s.%s" , prefix , name );
298+ }
299+ if ( qualifiedSignature != null ) {
300+ String completeName = String .format ("%s.%s" , ctype , name );
275301 if (rtc .getContext ().getFunction (completeName , ctype , argSize ) != null ) {
276302 checkInvocationRefinements (invocation , invocation .getArguments (), invocation .getTarget (), completeName ,
277303 ctype );
@@ -284,6 +310,8 @@ private Map<String, String> checkInvocationRefinements(CtElement invocation, Lis
284310 // -- Part 1: Check if the invocation is possible
285311 int si = arguments .size ();
286312 RefinedFunction f = rtc .getContext ().getFunction (methodName , className , si );
313+ if (f == null )
314+ return new HashMap <>();
287315 Map <String , String > map = mapInvocation (arguments , f );
288316
289317 if (target != null ) {
0 commit comments