@@ -29,29 +29,8 @@ void ConstraintSystem::PotentialBindings::inferTransitiveBindings(
29
29
&inferredBindings) {
30
30
using BindingKind = ConstraintSystem::AllowedBindingKind;
31
31
32
- llvm::SmallVector<Constraint *, 4 > conversions;
33
- // First, let's collect all of the conversions associated
34
- // with this type variable.
35
- llvm::copy_if (
36
- Sources, std::back_inserter (conversions),
37
- [&](const Constraint *constraint) -> bool {
38
- if (constraint->getKind () != ConstraintKind::Subtype &&
39
- constraint->getKind () != ConstraintKind::Conversion &&
40
- constraint->getKind () != ConstraintKind::ArgumentConversion &&
41
- constraint->getKind () != ConstraintKind::OperatorArgumentConversion)
42
- return false ;
43
-
44
- auto rhs = cs.simplifyType (constraint->getSecondType ());
45
- return rhs->getAs <TypeVariableType>() == TypeVar;
46
- });
47
-
48
- for (auto *constraint : conversions) {
49
- auto *tv =
50
- cs.simplifyType (constraint->getFirstType ())->getAs <TypeVariableType>();
51
- if (!tv || tv == TypeVar)
52
- continue ;
53
-
54
- auto relatedBindings = inferredBindings.find (tv);
32
+ for (const auto &entry : SupertypeOf) {
33
+ auto relatedBindings = inferredBindings.find (entry.first );
55
34
if (relatedBindings == inferredBindings.end ())
56
35
continue ;
57
36
@@ -89,7 +68,7 @@ void ConstraintSystem::PotentialBindings::inferTransitiveBindings(
89
68
llvm::copy (bindings.Defaults , std::back_inserter (Defaults));
90
69
91
70
// TODO: We shouldn't need this in the future.
92
- if (constraint ->getKind () != ConstraintKind::Subtype)
71
+ if (entry. second ->getKind () != ConstraintKind::Subtype)
93
72
continue ;
94
73
95
74
for (auto &binding : bindings.Bindings ) {
@@ -670,10 +649,6 @@ ConstraintSystem::getPotentialBindingForRelationalConstraint(
670
649
671
650
auto *typeVar = result.TypeVar ;
672
651
673
- // Record constraint which contributes to the
674
- // finding of potential bindings.
675
- result.Sources .insert (constraint);
676
-
677
652
auto first = simplifyType (constraint->getFirstType ());
678
653
auto second = simplifyType (constraint->getSecondType ());
679
654
@@ -798,15 +773,16 @@ ConstraintSystem::getPotentialBindingForRelationalConstraint(
798
773
if (kind == AllowedBindingKind::Subtypes) {
799
774
result.SubtypeOf .insert ({bindingTypeVar, constraint});
800
775
} else {
801
- // TODO: record this type variable as a `supertypeOf`
776
+ assert (kind == AllowedBindingKind::Supertypes);
777
+ result.SupertypeOf .insert ({bindingTypeVar, constraint});
802
778
}
803
779
break ;
804
780
}
805
781
806
782
case ConstraintKind::Bind:
807
783
case ConstraintKind::BindParam:
808
784
case ConstraintKind::Equal: {
809
- // TODO: record this type variable as being equal to other type variable.
785
+ result. EquivalentTo . insert ({bindingTypeVar, constraint});
810
786
break ;
811
787
}
812
788
0 commit comments