mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
RequirementMachine: Don't add unnecessary rule in merged associated types step
If we have a rewrite rule of the form
X.[P:A] => X.[Q:A]
We introduce a pair of rules
X.[P:A] => X.[P&Q:A]
X.[Q:A] => X.[P&Q:A]
But in reality only the second one is necessary. The first one is redundant
because you obtain the same result by applying the original rule followed by
the second rule.
This commit is contained in:
@@ -123,6 +123,10 @@ bool RewriteSystem::addRule(MutableTerm lhs, MutableTerm rhs) {
|
||||
lhs.back().getKind() == Symbol::Kind::AssociatedType &&
|
||||
rhs.back().getKind() == Symbol::Kind::AssociatedType &&
|
||||
lhs.back().getName() == rhs.back().getName()) {
|
||||
if (Debug.contains(DebugFlags::Merge)) {
|
||||
llvm::dbgs() << "## Associated type merge candidate ";
|
||||
llvm::dbgs() << lhs << " => " << rhs << "\n\n";
|
||||
}
|
||||
MergedAssociatedTypes.emplace_back(lhs, rhs);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user