Skip to content

Commit 8932b49

Browse files
committed
Don't Simplify Expected Type
1 parent e789e05 commit 8932b49

4 files changed

Lines changed: 17 additions & 18 deletions

File tree

liquidjava-verifier/src/main/java/liquidjava/diagnostics/errors/RefinementError.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import liquidjava.diagnostics.TranslationTable;
88
import liquidjava.processor.VCImplication;
9+
import liquidjava.rj_language.Predicate;
910
import liquidjava.rj_language.ast.Expression;
1011
import liquidjava.rj_language.ast.formatter.VariableFormatter;
1112
import liquidjava.smt.Counterexample;
@@ -18,15 +19,14 @@
1819
*/
1920
public class RefinementError extends LJError {
2021

21-
private final VCImplication expected;
22+
private final Predicate expected;
2223
private final VCImplication found;
2324
private final Counterexample counterexample;
2425

25-
public RefinementError(SourcePosition position, VCImplication expected, VCImplication found,
26+
public RefinementError(SourcePosition position, Predicate expected, VCImplication found,
2627
TranslationTable translationTable, Counterexample counterexample, String customMessage) {
27-
super("Refinement Error",
28-
String.format("%s is not a subtype of %s", found.toPredicate().getExpression().toDisplayString(),
29-
expected.toPredicate().getExpression().toDisplayString()),
28+
super("Refinement Error", String.format("%s is not a subtype of %s",
29+
found.toPredicate().getExpression().toDisplayString(), expected.getExpression().toDisplayString()),
3030
position, translationTable, customMessage);
3131
this.expected = expected;
3232
this.found = found;
@@ -47,7 +47,7 @@ public String getCounterExampleString() {
4747

4848
List<String> foundVarNames = new ArrayList<>();
4949
Expression foundExpression = found.toPredicate().getExpression();
50-
Expression expectedExpression = expected.toPredicate().getExpression();
50+
Expression expectedExpression = expected.getExpression();
5151
foundExpression.getVariableNames(foundVarNames);
5252
// also keep resolved static-final constants (e.g. Integer.MAX_VALUE) referenced by either side of the
5353
// subtyping check, so the counterexample maps the symbolic name back to its compile-time value
@@ -73,7 +73,7 @@ public Counterexample getCounterexample() {
7373
return counterexample;
7474
}
7575

76-
public VCImplication getExpected() {
76+
public Predicate getExpected() {
7777
return expected;
7878
}
7979

liquidjava-verifier/src/main/java/liquidjava/diagnostics/errors/StateRefinementError.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import liquidjava.diagnostics.TranslationTable;
44
import liquidjava.processor.VCImplication;
5+
import liquidjava.rj_language.Predicate;
56
import spoon.reflect.cu.SourcePosition;
67

78
/**
@@ -11,21 +12,20 @@
1112
*/
1213
public class StateRefinementError extends LJError {
1314

14-
private final VCImplication expected;
15+
private final Predicate expected;
1516
private final VCImplication found;
1617

17-
public StateRefinementError(SourcePosition position, VCImplication expected, VCImplication found,
18+
public StateRefinementError(SourcePosition position, Predicate expected, VCImplication found,
1819
TranslationTable translationTable, String customMessage) {
1920
super("State Refinement Error",
20-
String.format("Expected state %s but found %s",
21-
expected.toPredicate().getExpression().toDisplayString(),
21+
String.format("Expected state %s but found %s", expected.getExpression().toDisplayString(),
2222
found.toPredicate().getExpression().toDisplayString()),
2323
position, translationTable, customMessage);
2424
this.expected = expected;
2525
this.found = found;
2626
}
2727

28-
public VCImplication getExpected() {
28+
public Predicate getExpected() {
2929
return expected;
3030
}
3131

liquidjava-verifier/src/main/java/liquidjava/processor/refinement_checker/VCChecker.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ public void processSubtyping(Predicate expectedType, List<GhostState> list, CtEl
8282
}
8383
DebugLog.smtResult(result);
8484
if (result.isError()) {
85-
throw new RefinementError(element.getPosition(), expectedType.simplify(context),
86-
implBeforeChange.simplify(), map, result.getCounterexample(), customMessage);
85+
throw new RefinementError(element.getPosition(), expectedType, implBeforeChange.simplify(), map,
86+
result.getCounterexample(), customMessage);
8787
}
8888
}
8989

@@ -407,15 +407,14 @@ protected void throwRefinementError(SourcePosition position, Predicate expected,
407407
Counterexample counterexample, String customMessage) throws RefinementError {
408408
TranslationTable map = new TranslationTable();
409409
VCImplication premises = buildPremiseChain(map, expected, found);
410-
throw new RefinementError(position, expected.simplify(context), premises.simplify(), map, counterexample,
411-
customMessage);
410+
throw new RefinementError(position, expected, premises.simplify(), map, counterexample, customMessage);
412411
}
413412

414413
protected void throwStateRefinementError(SourcePosition position, Predicate found, Predicate expected,
415414
String customMessage) throws StateRefinementError {
416415
TranslationTable map = new TranslationTable();
417416
VCImplication foundState = buildPremiseChain(map, expected, found);
418-
throw new StateRefinementError(position, expected.simplify(context), foundState.simplify(), map, customMessage);
417+
throw new StateRefinementError(position, expected, foundState.simplify(), map, customMessage);
419418
}
420419

421420
protected void throwStateConflictError(SourcePosition position, Predicate expected) throws StateConflictError {

liquidjava-verifier/src/main/java/liquidjava/rj_language/Predicate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ public Predicate getOrigin() {
259259
return this;
260260
}
261261

262-
public VCImplication simplify(Context context) {
262+
public VCImplication simplify() {
263263
VCImplication result = new VCImplication(clone()).simplify();
264264
DebugLog.simplification(this.getExpression(), result.getRefinement().getExpression());
265265
return result;

0 commit comments

Comments
 (0)