mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[ConstraintGraph] Add filtering to gatherConstraints per type variable
Most of the use-cases of `gatherConstraints` require filtering at least based on the constraint kind that caller is interested in, so instead of returning unrelated results and asking caller to filter separately, let's add that functionality directly to `gatherConstraints`.
This commit is contained in:
@@ -213,17 +213,16 @@ void ConstraintSystem::setMustBeMaterializableRecursive(Type type)
|
||||
void ConstraintSystem::addTypeVariableConstraintsToWorkList(
|
||||
TypeVariableType *typeVar) {
|
||||
// Gather the constraints affected by a change to this type variable.
|
||||
SmallPtrSet<Constraint *, 8> constraints;
|
||||
CG.gatherConstraints(typeVar, constraints,
|
||||
ConstraintGraph::GatheringKind::AllMentions);
|
||||
SmallPtrSet<Constraint *, 8> inactiveConstraints;
|
||||
CG.gatherConstraints(
|
||||
typeVar, inactiveConstraints, ConstraintGraph::GatheringKind::AllMentions,
|
||||
[](Constraint *constraint) { return !constraint->isActive(); });
|
||||
|
||||
// Add any constraints that aren't already active to the worklist.
|
||||
for (auto constraint : constraints) {
|
||||
if (!constraint->isActive()) {
|
||||
ActiveConstraints.splice(ActiveConstraints.end(),
|
||||
InactiveConstraints, constraint);
|
||||
constraint->setActive(true);
|
||||
}
|
||||
for (auto constraint : inactiveConstraints) {
|
||||
ActiveConstraints.splice(ActiveConstraints.end(), InactiveConstraints,
|
||||
constraint);
|
||||
constraint->setActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user