@@ -334,34 +334,23 @@ void RewriteSystem::simplifyLeftHandSideSubstitutions(const PropertyMap *map) {
334334
335335 auto symbol = *optSymbol;
336336
337- RewritePath path;
338-
339- auto differenceID = simplifySubstitutions (rule.getRHS (), symbol, map, &path);
337+ auto differenceID = simplifySubstitutions (rule.getRHS (), symbol, map);
340338 if (!differenceID)
341339 continue ;
342340
343- rule.markSubstitutionSimplified ();
344-
345341 auto difference = getTypeDifference (*differenceID);
346342 assert (difference.LHS == symbol);
343+ assert (difference.RHS != symbol);
347344
348- // If the original rule is (T.[concrete: C] => T) and [concrete: C'] is
349- // the simplified symbol, then difference.LHS == [concrete: C] and
350- // difference.RHS == [concrete: C'], and the rewrite path we just
351- // built takes T.[concrete: C] to T.[concrete: C'].
352- //
353- // We want a path from T.[concrete: C'] to T, so invert the path to get
354- // a path from T.[concrete: C'] to T.[concrete: C], and add a final step
355- // applying the original rule (T.[concrete: C] => T).
356- path.invert ();
357- path.add (RewriteStep::forRewriteRule (/* startOffset=*/ 0 ,
358- /* endOffset=*/ 0 ,
359- /* ruleID=*/ ruleID,
360- /* inverted=*/ false ));
361345 MutableTerm rhs (rule.getRHS ());
362346 MutableTerm lhs (rhs);
363347 lhs.add (difference.RHS );
364348
365- addRule (lhs, rhs, &path);
349+ addRule (lhs, rhs);
350+
351+ RewritePath path;
352+ buildRewritePathForJoiningTerms (rhs, lhs, &path);
353+
354+ processTypeDifference (difference, *differenceID, ruleID, path);
366355 }
367356}
0 commit comments