@@ -334,34 +334,23 @@ void RewriteSystem::simplifyLeftHandSideSubstitutions(const PropertyMap *map) {
334
334
335
335
auto symbol = *optSymbol;
336
336
337
- RewritePath path;
338
-
339
- auto differenceID = simplifySubstitutions (rule.getRHS (), symbol, map, &path);
337
+ auto differenceID = simplifySubstitutions (rule.getRHS (), symbol, map);
340
338
if (!differenceID)
341
339
continue ;
342
340
343
- rule.markSubstitutionSimplified ();
344
-
345
341
auto difference = getTypeDifference (*differenceID);
346
342
assert (difference.LHS == symbol);
343
+ assert (difference.RHS != symbol);
347
344
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 ));
361
345
MutableTerm rhs (rule.getRHS ());
362
346
MutableTerm lhs (rhs);
363
347
lhs.add (difference.RHS );
364
348
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);
366
355
}
367
356
}
0 commit comments