Skip to content
Open
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,13 @@
// Invalid Refinement Error
package testSuite;

import liquidjava.specification.Refinement;

@SuppressWarnings("unused")
public class ErrorInvalidRefinement {

void test() {
@Refinement("x")
int x = 0;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Invalid Refinement Error
package testSuite;

import liquidjava.specification.Refinement;

public class ErrorInvalidRefinementParameter {

void testInvalidRefinement(@Refinement("y + 1") int y) {}

int otherMethod() {
return -1;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Invalid Refinement Error
package testSuite;

import liquidjava.specification.Refinement;

public class ErrorInvalidRefinementReturn {

@Refinement("_ * 2")
void test() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class InvalidRefinementError extends LJError {
private final String refinement;

public InvalidRefinementError(SourcePosition position, String message, String refinement) {
super("Invalid Refinement", message, position, null);
super("Invalid Refinement Error", message, position, null);
this.refinement = refinement;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,24 @@ public <T> void visitCtInterface(CtInterface<T> intrface) {
@Override
public <T> void visitCtConstructor(CtConstructor<T> c) {
context.enterContext();
getRefinementFromAnnotation(c);
mfc.getConstructorRefinements(c);
super.visitCtConstructor(c);
try {
getRefinementFromAnnotation(c);
mfc.getConstructorRefinements(c);
super.visitCtConstructor(c);
} catch (LJError e) {
diagnostics.add(e);
}
context.exitContext();
}

public <R> void visitCtMethod(CtMethod<R> method) {
context.enterContext();
mfc.getMethodRefinements(method);
super.visitCtMethod(method);
try {
mfc.getMethodRefinements(method);
super.visitCtMethod(method);
} catch (LJError e) {
diagnostics.add(e);
}
context.exitContext();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ public <R> void getReturnRefinements(CtReturn<R> ret) throws LJError {
if (method.getParent() instanceof CtClass) {
RefinedFunction fi = rtc.getContext().getFunction(method.getSimpleName(),
((CtClass<?>) method.getParent()).getQualifiedName(), method.getParameters().size());
if (fi == null)
return;
Comment on lines +184 to +185
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just in case.


List<Variable> lv = fi.getArguments();
for (Variable v : lv) {
Expand Down Expand Up @@ -411,10 +413,6 @@ public void loadFunctionInfo(CtExecutable<?> method) {
List<Variable> lv = fi.getArguments();
for (Variable v : lv)
rtc.getContext().addVarToContext(v);
} else {
assert false;
// Method should already be in context. Should not arrive this point in
// refinement checker.
Comment on lines -414 to -417
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot assume this anymore because a method that throws InvalidRefinementError on a parametric refinement will not be added to the context.

}
}
}
Expand Down