Skip to content

Commit 1da75ac

Browse files
committed
Reviewed Changes
1 parent b064cef commit 1da75ac

File tree

2 files changed

+2
-40
lines changed

2 files changed

+2
-40
lines changed

liquidjava-verifier/src/main/java/liquidjava/processor/context/Context.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ public RefinedFunction getFunction(String name, String target, List<CtTypeRefere
306306
&& argumentTypesMatch(fi.getArguments(), paramTypes))
307307
return fi;
308308
}
309-
return null;
309+
return getFunction(name, target, paramTypes.size());
310310
}
311311

312312
private boolean argumentTypesMatch(List<Variable> args, List<CtTypeReference<?>> paramTypes) {

liquidjava-verifier/src/main/java/liquidjava/processor/refinement_checker/general_checkers/MethodsFunctionsChecker.java

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ public void getConstructorInvocationRefinements(CtConstructorCall<?> ctConstruct
6464
List<CtTypeReference<?>> paramTypes = exe.getParameters();
6565
RefinedFunction f = rtc.getContext().getFunction(exe.getSimpleName(),
6666
exe.getDeclaringType().getQualifiedName(), paramTypes);
67-
if (f == null)
68-
f = rtc.getContext().getFunction(exe.getSimpleName(), exe.getDeclaringType().getQualifiedName(),
69-
ctConstructorCall.getArguments().size());
7067
if (f != null) {
7168
Map<String, String> map = checkInvocationRefinements(ctConstructorCall,
7269
ctConstructorCall.getArguments(), ctConstructorCall.getTarget(), f.getName(),
@@ -227,32 +224,13 @@ public <R> void getInvocationRefinements(CtInvocation<R> invocation) throws LJEr
227224
String ctype = ((CtClass<?>) method.getParent()).getQualifiedName();
228225
List<CtTypeReference<?>> paramTypes = invocation.getExecutable().getParameters();
229226
RefinedFunction f = rtc.getContext().getFunction(method.getSimpleName(), ctype, paramTypes);
230-
if (f == null)
231-
f = rtc.getContext().getFunction(method.getSimpleName(), ctype, invocation.getArguments().size());
232227
if (f != null) { // inside rtc.context
233228
checkInvocationRefinements(invocation, invocation.getArguments(), invocation.getTarget(),
234229
method.getSimpleName(), ctype, paramTypes);
235230
}
236231
}
237232
}
238233

239-
public RefinedFunction getRefinementFunction(String methodName, String className, int size) {
240-
RefinedFunction f = rtc.getContext().getFunction(methodName, className, size);
241-
if (f == null)
242-
f = rtc.getContext().getFunction(String.format("%s.%s", className, methodName), className, size);
243-
return f;
244-
}
245-
246-
public RefinedFunction getRefinementFunction(String methodName, String className,
247-
List<CtTypeReference<?>> paramTypes) {
248-
RefinedFunction f = rtc.getContext().getFunction(methodName, className, paramTypes);
249-
if (f == null)
250-
f = rtc.getContext().getFunction(String.format("%s.%s", className, methodName), className, paramTypes);
251-
if (f == null)
252-
f = getRefinementFunction(methodName, className, paramTypes.size());
253-
return f;
254-
}
255-
256234
private void searchMethodInLibrary(CtExecutableReference<?> ctr, CtInvocation<?> invocation) throws LJError {
257235
CtTypeReference<?> ctref = ctr.getDeclaringType();
258236
if (ctref == null) {
@@ -263,14 +241,11 @@ private void searchMethodInLibrary(CtExecutableReference<?> ctr, CtInvocation<?>
263241
String ctype = (ctref != null) ? ctref.toString() : null;
264242

265243
String name = ctr.getSimpleName(); // missing
266-
int argSize = invocation.getArguments().size();
267244
List<CtTypeReference<?>> paramTypes = ctr.getParameters();
268245
String qualifiedSignature = null;
269246
if (ctype != null) {
270247
qualifiedSignature = String.format("%s.%s", ctype, ctr.getSignature());
271248
RefinedFunction f = rtc.getContext().getFunction(qualifiedSignature, ctype, paramTypes);
272-
if (f == null)
273-
f = rtc.getContext().getFunction(qualifiedSignature, ctype, argSize);
274249
if (f != null) {
275250
checkInvocationRefinements(invocation, invocation.getArguments(), invocation.getTarget(),
276251
qualifiedSignature, ctype, paramTypes);
@@ -279,16 +254,12 @@ private void searchMethodInLibrary(CtExecutableReference<?> ctr, CtInvocation<?>
279254
}
280255
String signature = ctr.getSignature();
281256
RefinedFunction f = rtc.getContext().getFunction(signature, ctype, paramTypes);
282-
if (f == null)
283-
f = rtc.getContext().getFunction(signature, ctype, argSize);
284257
if (f != null) {
285258
checkInvocationRefinements(invocation, invocation.getArguments(), invocation.getTarget(), signature, ctype,
286259
paramTypes);
287260
return;
288261
}
289262
f = rtc.getContext().getFunction(name, ctype, paramTypes);
290-
if (f == null)
291-
f = rtc.getContext().getFunction(name, ctype, argSize);
292263
if (f != null) { // inside rtc.context
293264
checkInvocationRefinements(invocation, invocation.getArguments(), invocation.getTarget(), name, ctype,
294265
paramTypes);
@@ -297,29 +268,20 @@ private void searchMethodInLibrary(CtExecutableReference<?> ctr, CtInvocation<?>
297268
if (qualifiedSignature != null) {
298269
String completeName = String.format("%s.%s", ctype, name);
299270
f = rtc.getContext().getFunction(completeName, ctype, paramTypes);
300-
if (f == null)
301-
f = rtc.getContext().getFunction(completeName, ctype, argSize);
302271
if (f != null) {
303272
checkInvocationRefinements(invocation, invocation.getArguments(), invocation.getTarget(), completeName,
304273
ctype, paramTypes);
305274
}
306275
}
307276
}
308277

309-
private Map<String, String> checkInvocationRefinements(CtElement invocation, List<CtExpression<?>> arguments,
310-
CtExpression<?> target, String methodName, String className) throws LJError {
311-
return checkInvocationRefinements(invocation, arguments, target, methodName, className, null);
312-
}
313-
314278
private Map<String, String> checkInvocationRefinements(CtElement invocation, List<CtExpression<?>> arguments,
315279
CtExpression<?> target, String methodName, String className, List<CtTypeReference<?>> paramTypes)
316280
throws LJError {
317281
// -- Part 1: Check if the invocation is possible
318282
RefinedFunction f = null;
319283
if (paramTypes != null)
320284
f = rtc.getContext().getFunction(methodName, className, paramTypes);
321-
if (f == null)
322-
f = rtc.getContext().getFunction(methodName, className, arguments.size());
323285
if (f == null)
324286
return new HashMap<>();
325287
Map<String, String> map = mapInvocation(arguments, f);
@@ -451,7 +413,7 @@ public void loadFunctionInfo(CtExecutable<?> method) {
451413
List<CtTypeReference<?>> paramTypes = new ArrayList<>();
452414
for (CtParameter<?> p : method.getParameters())
453415
paramTypes.add(p.getType());
454-
RefinedFunction fi = getRefinementFunction(method.getSimpleName(), className, paramTypes);
416+
RefinedFunction fi = rtc.getContext().getFunction(method.getSimpleName(), className, paramTypes);
455417
if (fi != null) {
456418
List<Variable> lv = fi.getArguments();
457419
for (Variable v : lv)

0 commit comments

Comments
 (0)