55import java .util .stream .Collectors ;
66
77import liquidjava .diagnostics .TranslationTable ;
8+ import liquidjava .processor .VCImplication ;
9+ import liquidjava .rj_language .Predicate ;
810import liquidjava .rj_language .ast .Expression ;
911import liquidjava .rj_language .ast .formatter .VariableFormatter ;
10- import liquidjava .rj_language .opt .derivation_node .ValDerivationNode ;
1112import liquidjava .smt .Counterexample ;
1213import spoon .reflect .cu .SourcePosition ;
1314
1819 */
1920public class RefinementError extends LJError {
2021
21- private final ValDerivationNode expected ;
22- private final ValDerivationNode found ;
22+ private final Predicate expected ;
23+ private final VCImplication found ;
2324 private final Counterexample counterexample ;
2425
25- public RefinementError (SourcePosition position , ValDerivationNode expected , ValDerivationNode found ,
26+ public RefinementError (SourcePosition position , Predicate expected , VCImplication found ,
2627 TranslationTable translationTable , Counterexample counterexample , String customMessage ) {
27- super ("Refinement Error" , String .format ("%s is not a subtype of %s" , found .getValue ().toDisplayString (),
28- expected .getValue ().toDisplayString ()), position , translationTable , customMessage );
28+ super ("Refinement Error" , String .format ("%s is not a subtype of %s" ,
29+ found .toPredicate ().getExpression ().toDisplayString (), expected .getExpression ().toDisplayString ()),
30+ position , translationTable , customMessage );
2931 this .expected = expected ;
3032 this .found = found ;
3133 this .counterexample = counterexample ;
@@ -44,12 +46,14 @@ public String getCounterExampleString() {
4446 return null ;
4547
4648 List <String > foundVarNames = new ArrayList <>();
47- found .getValue ().getVariableNames (foundVarNames );
49+ Expression foundExpression = found .toPredicate ().getExpression ();
50+ Expression expectedExpression = expected .getExpression ();
51+ foundExpression .getVariableNames (foundVarNames );
4852 // also keep resolved static-final constants (e.g. Integer.MAX_VALUE) referenced by either side of the
4953 // subtyping check, so the counterexample maps the symbolic name back to its compile-time value
50- found . getValue () .getResolvedConstantNames (foundVarNames );
51- expected . getValue () .getResolvedConstantNames (foundVarNames );
52- List <String > foundAssignments = found . getValue () .getConjuncts ().stream ().map (Expression ::toString ).toList ();
54+ foundExpression .getResolvedConstantNames (foundVarNames );
55+ expectedExpression .getResolvedConstantNames (foundVarNames );
56+ List <String > foundAssignments = foundExpression .getConjuncts ().stream ().map (Expression ::toString ).toList ();
5357 String counterexampleString = counterexample .assignments ().stream ()
5458 // only include variables that appear in the found value and are not already fixed there
5559 .filter (a -> foundVarNames .contains (a .first ())
@@ -69,11 +73,11 @@ public Counterexample getCounterexample() {
6973 return counterexample ;
7074 }
7175
72- public ValDerivationNode getExpected () {
76+ public Predicate getExpected () {
7377 return expected ;
7478 }
7579
76- public ValDerivationNode getFound () {
80+ public VCImplication getFound () {
7781 return found ;
7882 }
7983}
0 commit comments