Skip to content

Commit 0686cd5

Browse files
committed
RequirementMachine: Better assertions for generating conformances
1 parent 2f2249c commit 0686cd5

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

lib/AST/RequirementMachine/GeneratingConformances.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ void RewriteSystem::verifyGeneratingConformanceEquations(
518518
const auto &rule = getRule(pair.first);
519519
auto *proto = rule.getLHS().back().getProtocol();
520520

521-
MutableTerm baseTerm(rule.getLHS());
521+
MutableTerm baseTerm(rule.getRHS());
522522
(void) simplify(baseTerm);
523523

524524
for (const auto &path : pair.second) {
@@ -541,8 +541,23 @@ void RewriteSystem::verifyGeneratingConformanceEquations(
541541
}
542542

543543
MutableTerm otherTerm;
544-
for (unsigned otherRuleID : path) {
545-
otherTerm.append(getRule(otherRuleID).getLHS());
544+
for (unsigned i : indices(path)) {
545+
unsigned otherRuleID = path[i];
546+
const auto &rule = getRule(otherRuleID);
547+
548+
bool isLastElement = (i == path.size() - 1);
549+
if ((isLastElement && !rule.isAnyConformanceRule()) ||
550+
(!isLastElement && !rule.isProtocolConformanceRule())) {
551+
llvm::errs() << "Equation term is not a conformance rule: ";
552+
dumpGeneratingConformanceEquation(llvm::errs(),
553+
pair.first, pair.second);
554+
llvm::errs() << "\n";
555+
llvm::errs() << "Term: " << rule << "\n";
556+
dump(llvm::errs());
557+
abort();
558+
}
559+
560+
otherTerm.append(rule.getRHS());
546561
}
547562

548563
(void) simplify(otherTerm);

0 commit comments

Comments
 (0)