@@ -53,6 +53,18 @@ BindingSet::BindingSet(ConstraintSystem &CS, TypeVariableType *TypeVar,
53
53
for (const auto &binding : info.Bindings )
54
54
addBinding (binding, /* isTransitive=*/ false );
55
55
56
+ for (auto *constraint : info.Constraints ) {
57
+ switch (constraint->getKind ()) {
58
+ case ConstraintKind::ConformsTo: {
59
+ if (constraint->getSecondType ()->is <ProtocolType>())
60
+ Protocols.push_back (constraint);
61
+ break ;
62
+ }
63
+ default :
64
+ break ;
65
+ }
66
+ }
67
+
56
68
for (auto *literal : info.Literals )
57
69
addLiteralRequirement (literal);
58
70
@@ -1956,6 +1968,7 @@ void PotentialBindings::infer(ConstraintSystem &CS,
1956
1968
case ConstraintKind::PackElementOf:
1957
1969
case ConstraintKind::SameShape:
1958
1970
case ConstraintKind::MaterializePackExpansion:
1971
+ case ConstraintKind::ConformsTo:
1959
1972
// Constraints from which we can't do anything.
1960
1973
break ;
1961
1974
@@ -1996,13 +2009,6 @@ void PotentialBindings::infer(ConstraintSystem &CS,
1996
2009
DelayedBy.push_back (constraint);
1997
2010
break ;
1998
2011
1999
- case ConstraintKind::ConformsTo: {
2000
- auto protocolTy = constraint->getSecondType ();
2001
- if (protocolTy->is <ProtocolType>())
2002
- Protocols.push_back (constraint);
2003
- break ;
2004
- }
2005
-
2006
2012
case ConstraintKind::LiteralConformsTo: {
2007
2013
// Record constraint where protocol requirement originated
2008
2014
// this is useful to use for the binding later.
@@ -2084,7 +2090,7 @@ void PotentialBindings::retract(ConstraintSystem &CS,
2084
2090
2085
2091
LLVM_DEBUG (
2086
2092
llvm::dbgs () << Constraints.size () << " " << Bindings.size () << " "
2087
- << Protocols. size () << " " << Literals.size () << " "
2093
+ << Literals.size () << " "
2088
2094
<< AdjacentVars.size () << " " << DelayedBy.size () << " "
2089
2095
<< SubtypeOf.size () << " " << SupertypeOf.size () << " "
2090
2096
<< EquivalentTo.size () << " \n " );
@@ -2096,22 +2102,7 @@ void PotentialBindings::retract(ConstraintSystem &CS,
2096
2102
}),
2097
2103
Bindings.end ());
2098
2104
2099
- auto isMatchingConstraint = [&constraint](Constraint *existing) {
2100
- return existing == constraint;
2101
- };
2102
-
2103
- auto hasMatchingSource =
2104
- [&constraint](
2105
- const std::pair<TypeVariableType *, Constraint *> &adjacency) {
2106
- return adjacency.second == constraint;
2107
- };
2108
-
2109
2105
switch (constraint->getKind ()) {
2110
- case ConstraintKind::ConformsTo:
2111
- Protocols.erase (llvm::remove_if (Protocols, isMatchingConstraint),
2112
- Protocols.end ());
2113
- break ;
2114
-
2115
2106
case ConstraintKind::LiteralConformsTo:
2116
2107
Literals.erase (constraint);
2117
2108
break ;
@@ -2137,9 +2128,19 @@ void PotentialBindings::retract(ConstraintSystem &CS,
2137
2128
AdjacentVars.erase (std::make_pair (adjacentVar, constraint));
2138
2129
}
2139
2130
2131
+ auto isMatchingConstraint = [&constraint](Constraint *existing) {
2132
+ return existing == constraint;
2133
+ };
2134
+
2140
2135
DelayedBy.erase (llvm::remove_if (DelayedBy, isMatchingConstraint),
2141
2136
DelayedBy.end ());
2142
2137
2138
+ auto hasMatchingSource =
2139
+ [&constraint](
2140
+ const std::pair<TypeVariableType *, Constraint *> &adjacency) {
2141
+ return adjacency.second == constraint;
2142
+ };
2143
+
2143
2144
SubtypeOf.remove_if (hasMatchingSource);
2144
2145
SupertypeOf.remove_if (hasMatchingSource);
2145
2146
EquivalentTo.remove_if (hasMatchingSource);
@@ -2149,7 +2150,6 @@ void PotentialBindings::reset() {
2149
2150
if (CONDITIONAL_ASSERT_enabled ()) {
2150
2151
ASSERT (Constraints.empty ());
2151
2152
ASSERT (Bindings.empty ());
2152
- ASSERT (Protocols.empty ());
2153
2153
ASSERT (Literals.empty ());
2154
2154
ASSERT (Defaults.empty ());
2155
2155
ASSERT (DelayedBy.empty ());
0 commit comments