@@ -442,24 +442,15 @@ llvm::TinyPtrVector<Constraint *> ConstraintGraph::gatherConstraints(
442442 llvm::function_ref<bool (Constraint *)> acceptConstraintFn) {
443443 llvm::TinyPtrVector<Constraint *> constraints;
444444 // Whether we should consider this constraint at all.
445- auto rep = CS.getRepresentative (typeVar);
446445 auto shouldConsiderConstraint = [&](Constraint *constraint) {
447- // For a one-way constraint, only consider it when the type variable
448- // is on the right-hand side of the the binding, and the left-hand side of
449- // the binding is one of the type variables currently under consideration.
446+ // For a one-way constraint, only consider it when the left-hand side of
447+ // the binding is one of the type variables currently under consideration,
448+ // as only such constraints need solving for this component. Note that we
449+ // don't perform any other filtering, as the constraint system should be
450+ // responsible for checking any other conditions.
450451 if (constraint->isOneWayConstraint ()) {
451- auto lhsTypeVar =
452- constraint->getFirstType ()->castTo <TypeVariableType>();
453- if (!CS.isActiveTypeVariable (lhsTypeVar))
454- return false ;
455-
456- SmallVector<TypeVariableType *, 2 > rhsTypeVars;
457- constraint->getSecondType ()->getTypeVariables (rhsTypeVars);
458- for (auto rhsTypeVar : rhsTypeVars) {
459- if (CS.getRepresentative (rhsTypeVar) == rep)
460- return true ;
461- }
462- return false ;
452+ auto lhsTypeVar = constraint->getFirstType ()->castTo <TypeVariableType>();
453+ return CS.isActiveTypeVariable (lhsTypeVar);
463454 }
464455
465456 return true ;
0 commit comments