@@ -56,43 +56,41 @@ public void processSubtyping(Predicate expectedType, List<GhostState> list, CtEl
5656 e .setPosition (element .getPosition ());
5757 throw e ;
5858 }
59- SMTResult result = smtChecks (expected , premises , element .getPosition ());
59+ SMTResult result = verifySMTSubtype (expected , premises , element .getPosition ());
6060 if (result .isError ()) {
6161 throw new RefinementError (element .getPosition (), expectedType .simplify (), premisesBeforeChange .simplify (),
6262 map , result .getCounterexample (), customMessage );
6363 }
6464 }
6565
6666 /**
67- * Check that type is a subtype of expectedType Throws RefinementError otherwise
68- *
67+ * Checks if type is a subtype of expectedType
68+ *
6969 * @param type
7070 * @param expectedType
7171 * @param list
7272 * @param element
7373 * @param f
74- *
74+ *
7575 * @throws LJError
7676 */
7777 public void processSubtyping (Predicate type , Predicate expectedType , List <GhostState > list , CtElement element ,
7878 Factory f ) throws LJError {
79- SMTResult result = canProcessSubtyping (type , expectedType , list , element .getPosition (), f );
79+ SMTResult result = verifySMTSubtypeStates (type , expectedType , list , element .getPosition (), f );
8080 if (result .isError ())
8181 throwRefinementError (element .getPosition (), expectedType , type , result .getCounterexample (), null );
8282 }
8383
8484 /**
85- * Checks the expected against the found constraint
86- *
85+ * Verifies whether the found predicate is a subtype of the expected predicate
86+ *
8787 * @param expected
8888 * @param found
8989 * @param position
90- *
91- * @return counterexample if expected type is not subtype of found type, otherwise null
92- *
93- * @throws LJError
90+ *
91+ * @return the result of the verification, containing a counterexample if the verification fails
9492 */
95- public SMTResult smtChecks (Predicate expected , Predicate found , SourcePosition position ) throws LJError {
93+ public SMTResult verifySMTSubtype (Predicate expected , Predicate found , SourcePosition position ) throws LJError {
9694 try {
9795 return new SMTEvaluator ().verifySubtype (found , expected , context );
9896 } catch (LJError e ) {
@@ -103,8 +101,19 @@ public SMTResult smtChecks(Predicate expected, Predicate found, SourcePosition p
103101 }
104102 }
105103
106- public SMTResult canProcessSubtyping (Predicate type , Predicate expectedType , List <GhostState > list ,
107- SourcePosition position , Factory f ) throws LJError {
104+ /**
105+ * Verifies whether the found predicate is a subtype of the expected predicate, taking into account the ghost states
106+ *
107+ * @param type
108+ * @param expectedType
109+ * @param states
110+ * @param position
111+ * @param factory
112+ *
113+ * @return the result of the verification, containing a counterexample if the verification fails
114+ */
115+ public SMTResult verifySMTSubtypeStates (Predicate type , Predicate expectedType , List <GhostState > states ,
116+ SourcePosition position , Factory factory ) throws LJError {
108117 List <RefinedVariable > lrv = new ArrayList <>(), mainVars = new ArrayList <>();
109118 gatherVariables (expectedType , lrv , mainVars );
110119 gatherVariables (type , lrv , mainVars );
@@ -114,13 +123,14 @@ public SMTResult canProcessSubtyping(Predicate type, Predicate expectedType, Lis
114123 TranslationTable map = new TranslationTable ();
115124 String [] s = { Keys .WILDCARD , Keys .THIS };
116125 Predicate premises = joinPredicates (expectedType , mainVars , lrv , map ).toConjunctions ();
117- List <GhostState > filtered = filterGhostStatesForVariables (list , mainVars , lrv );
126+ List <GhostState > filtered = filterGhostStatesForVariables (states , mainVars , lrv );
118127 premises = Predicate .createConjunction (premises , type ).changeStatesToRefinements (filtered , s )
119- .changeAliasToRefinement (context , f );
120- Predicate expected = expectedType .changeStatesToRefinements (filtered , s ).changeAliasToRefinement (context , f );
128+ .changeAliasToRefinement (context , factory );
129+ Predicate expected = expectedType .changeStatesToRefinements (filtered , s ).changeAliasToRefinement (context ,
130+ factory );
121131
122132 // check subtyping
123- return smtChecks (expected , premises , position );
133+ return verifySMTSubtype (expected , premises , position );
124134 }
125135
126136 /**
0 commit comments