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
Expand Up @@ -10,8 +10,10 @@ public void example() {
list.get(0);

Stack<Integer> stack = new Stack<>();
stack.push(1);
stack.peek();
if (stack.empty()) {
stack.push(1);
stack.peek();
}
stack.pop();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import liquidjava.specification.ExternalRefinementsFor;
import liquidjava.specification.Ghost;
import liquidjava.specification.Refinement;
import liquidjava.specification.StateRefinement;

@ExternalRefinementsFor("java.util.Stack")
Expand All @@ -18,4 +19,7 @@ public interface StackRefinements<E> {

@StateRefinement(from="size(this) > 0")
public E peek();

@Refinement("_ ? size(this) == 0 : size(this) > 0")
public boolean empty();
}
2 changes: 1 addition & 1 deletion liquidjava-verifier/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>io.github.liquid-java</groupId>
<artifactId>liquidjava-verifier</artifactId>
<version>0.0.27</version>
<version>0.0.28</version>
<name>liquidjava-verifier</name>
<description>LiquidJava Verifier</description>
<url>https://github.com/liquid-java/liquidjava</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ public Optional<Predicate> getRefinementFromAnnotation(CtElement element) throws
}
}
if (ref.isPresent()) {
Predicate p = new Predicate(ref.get(), element);
String prefix = getQualifiedClassName(element);
Predicate p = prefix == null ? new Predicate(ref.get(), element)
: new Predicate(ref.get(), element, prefix);
if (!p.getExpression().isBooleanExpression()) {
SourcePosition position = Utils.getLJAnnotationPosition(element, ref.get());
throw new InvalidRefinementError(position, "Refinement predicate must be a boolean expression",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getArgs() == null) ? 0 : getArgs().hashCode());
result = prime * result + ((name == null) ? 0 : Utils.getSimpleName(name).hashCode()); // same here
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}

Expand All @@ -114,10 +114,7 @@ public boolean equals(Object obj) {
if (name == null) {
return other.name == null;
} else {
// prefixes are inconsistent for refined class ghost calls: some use the
// original class prefix, others use the caller class prefix
// for now we compare simple names, but prefix handling should be fixed instead of having this workaround
return other.name != null && Utils.getSimpleName(name).equals(Utils.getSimpleName(other.name));
return name.equals(other.name);
}
}
}
Loading