Skip to content

Commit 57d89a6

Browse files
committed
RequirementMachine: Use processTypeDifference() in simplifyLeftHandSideSubstitutions()
1 parent f32b545 commit 57d89a6

File tree

2 files changed

+9
-20
lines changed

2 files changed

+9
-20
lines changed

lib/AST/RequirementMachine/RewriteSystem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ class RewriteSystem final {
318318

319319
Optional<unsigned>
320320
simplifySubstitutions(Term baseTerm, Symbol symbol, const PropertyMap *map,
321-
RewritePath *path);
321+
RewritePath *path=nullptr);
322322

323323
//////////////////////////////////////////////////////////////////////////////
324324
///

lib/AST/RequirementMachine/SimplifySubstitutions.cpp

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)