@@ -551,24 +551,21 @@ private static String addInstanceWithState(TypeChecker tc, String superName, Str
551551 prevInstance .getRefinement (), invocation );
552552 // vi2.setState(transitionedState);
553553 vi2 .setRefinement (transitionedState );
554- RefinedVariable rv = superName != null ? tc .getContext (). getVariableByName ( superName ) : null ;
555- if (rv != null ) {
556- // propagate supertypes from the refined variable
557- for (CtTypeReference <?> t : rv .getSuperTypes ())
554+ Context ctx = tc .getContext ();
555+ if (ctx . hasVariable ( superName ) ) {
556+ RefinedVariable rv = ctx . getVariableByName ( superName );
557+ for (CtTypeReference <?> t : rv .getSuperTypes ()) {
558558 vi2 .addSuperType (t );
559- } else {
560- // propagate supertypes from the previous instance
561- for (CtTypeReference <?> t : prevInstance .getSuperTypes ())
562- vi2 .addSuperType (t );
563- }
559+ }
564560
565- // if the variable is a parent (not a VariableInstance) we need to check that
566- // this refinement
567- // is a subtype of the variable's main refinement
568- if (rv instanceof Variable ) {
569- Predicate superC = rv .getMainRefinement ().substituteVariable (rv .getName (), vi2 .getName ());
570- tc .checkSMT (superC , invocation );
571- tc .getContext ().addRefinementInstanceToVariable (superName , name2 );
561+ // if the variable is a parent (not a VariableInstance) we need to check that
562+ // this refinement
563+ // is a subtype of the variable's main refinement
564+ if (rv instanceof Variable ) {
565+ Predicate superC = rv .getMainRefinement ().substituteVariable (rv .getName (), vi2 .getName ());
566+ tc .checkSMT (superC , invocation );
567+ tc .getContext ().addRefinementInstanceToVariable (superName , name2 );
568+ }
572569 }
573570
574571 invocation .putMetadata (tc .TARGET_KEY , vi2 );
0 commit comments