Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package testSuite.classes.method_overload_correct;

import liquidjava.specification.ExternalRefinementsFor;
import liquidjava.specification.Refinement;

@ExternalRefinementsFor("java.util.concurrent.Semaphore")
public interface DummySemaphoreRefinements {

public abstract void acquire();

public abstract void acquire(@Refinement("_ >= 0") int permits) throws InterruptedException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package testSuite.classes.method_overload_correct;

import java.util.concurrent.Semaphore;

public class TestMethodOverloadCorrect {
public static void main(String[] args) throws InterruptedException {
Semaphore sem = new Semaphore(1);
sem.acquire(1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public <R> void getReturnRefinements(CtReturn<R> ret) {
return;
if (method.getParent() instanceof CtClass) {
RefinedFunction fi = rtc.getContext().getFunction(method.getSimpleName(),
((CtClass<?>) method.getParent()).getQualifiedName());
((CtClass<?>) method.getParent()).getQualifiedName(), method.getParameters().size());

List<Variable> lv = fi.getArguments();
for (Variable v : lv) {
Expand Down Expand Up @@ -229,7 +229,8 @@ public <R> void getInvocationRefinements(CtInvocation<R> invocation) {

} else if (method.getParent() instanceof CtClass) {
String ctype = ((CtClass<?>) method.getParent()).getQualifiedName();
RefinedFunction f = rtc.getContext().getFunction(method.getSimpleName(), ctype);
int argSize = invocation.getArguments().size();
RefinedFunction f = rtc.getContext().getFunction(method.getSimpleName(), ctype, argSize);
if (f != null) { // inside rtc.context
checkInvocationRefinements(invocation, invocation.getArguments(), invocation.getTarget(),
method.getSimpleName(), ctype);
Expand Down Expand Up @@ -264,13 +265,14 @@ private void searchMethodInLibrary(CtExecutableReference<?> ctr, CtInvocation<?>
String ctype = (ctref != null) ? ctref.toString() : null;

String name = ctr.getSimpleName(); // missing
if (rtc.getContext().getFunction(name, ctype) != null) { // inside rtc.context
int argSize = invocation.getArguments().size();
if (rtc.getContext().getFunction(name, ctype, argSize) != null) { // inside rtc.context
checkInvocationRefinements(invocation, invocation.getArguments(), invocation.getTarget(), name, ctype);
return;
} else {
String prefix = ctype;
String completeName = String.format("%s.%s", prefix, name);
if (rtc.getContext().getFunction(completeName, ctype) != null) {
if (rtc.getContext().getFunction(completeName, ctype, argSize) != null) {
checkInvocationRefinements(invocation, invocation.getArguments(), invocation.getTarget(), completeName,
ctype);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ private Predicate getOperationRefinements(CtBinaryOperator<?> operator, CtVariab

// Get function refinements with non_used variables
String met = ((CtClass<?>) method.getParent()).getQualifiedName(); // TODO check
RefinedFunction fi = rtc.getContext().getFunction(method.getSimpleName(), met);
RefinedFunction fi = rtc.getContext().getFunction(method.getSimpleName(), met, inv.getArguments().size());
Predicate innerRefs = fi.getRenamedRefinements(rtc.getContext(), inv); // TODO REVER!!
// Substitute _ by the variable that we send
String newName = String.format(rtc.freshFormat, rtc.getContext().getCounter());
Expand All @@ -275,7 +275,8 @@ private Predicate getOperationRefinementFromExternalLib(CtInvocation<?> inv, CtB
int i = c.indexOf("<");
String typeNotParametrized = (i > 0) ? c.substring(0, i) : c;
String methodInClassName = typeNotParametrized + "." + simpleName;
RefinedFunction fi = rtc.getContext().getFunction(methodInClassName, typeNotParametrized);
RefinedFunction fi = rtc.getContext().getFunction(methodInClassName, typeNotParametrized,
inv.getArguments().size());
Predicate innerRefs = fi.getRenamedRefinements(rtc.getContext(), inv); // TODO REVER!!

// Substitute _ by the variable that we send
Expand Down