@@ -812,13 +812,8 @@ PotentialBindings ConstraintSystem::inferBindingsFor(TypeVariableType *typeVar,
812
812
auto constraints = CG.gatherConstraints (
813
813
typeVar, ConstraintGraph::GatheringKind::EquivalenceClass);
814
814
815
- for (auto *constraint : constraints) {
816
- bool failed = bindings.infer (constraint);
817
-
818
- // Upon inference failure let's produce an empty set of bindings.
819
- if (failed)
820
- return {*this , typeVar};
821
- }
815
+ for (auto *constraint : constraints)
816
+ bindings.infer (constraint);
822
817
823
818
if (finalize) {
824
819
llvm::SmallDenseMap<TypeVariableType *, PotentialBindings> inferred;
@@ -1068,7 +1063,7 @@ PotentialBindings::inferFromRelational(Constraint *constraint) {
1068
1063
// / Retrieve the set of potential type bindings for the given
1069
1064
// / representative type variable, along with flags indicating whether
1070
1065
// / those types should be opened.
1071
- bool PotentialBindings::infer (Constraint *constraint) {
1066
+ void PotentialBindings::infer (Constraint *constraint) {
1072
1067
switch (constraint->getKind ()) {
1073
1068
case ConstraintKind::Bind:
1074
1069
case ConstraintKind::Equal:
@@ -1152,8 +1147,10 @@ bool PotentialBindings::infer(Constraint *constraint) {
1152
1147
// [existential] metatype.
1153
1148
auto dynamicType = constraint->getFirstType ();
1154
1149
if (auto *tv = dynamicType->getAs <TypeVariableType>()) {
1155
- if (tv->getImpl ().getRepresentative (nullptr ) == TypeVar)
1156
- return true ;
1150
+ if (tv->getImpl ().getRepresentative (nullptr ) == TypeVar) {
1151
+ DelayedBy.push_back (constraint);
1152
+ break ;
1153
+ }
1157
1154
}
1158
1155
1159
1156
// This is right-hand side, let's continue.
@@ -1174,19 +1171,14 @@ bool PotentialBindings::infer(Constraint *constraint) {
1174
1171
// associated with closure literal (e.g. coercion to some other
1175
1172
// type) let's delay resolving the closure until the disjunction
1176
1173
// is attempted.
1177
- if (TypeVar->getImpl ().isClosureType ())
1178
- return true ;
1179
-
1180
1174
DelayedBy.push_back (constraint);
1181
1175
break ;
1182
1176
1183
1177
case ConstraintKind::ConformsTo:
1184
1178
case ConstraintKind::SelfObjectOfProtocol: {
1185
1179
auto protocolTy = constraint->getSecondType ();
1186
- if (!protocolTy->is <ProtocolType>())
1187
- return false ;
1188
-
1189
- Protocols.push_back (constraint);
1180
+ if (protocolTy->is <ProtocolType>())
1181
+ Protocols.push_back (constraint);
1190
1182
break ;
1191
1183
}
1192
1184
@@ -1247,15 +1239,15 @@ bool PotentialBindings::infer(Constraint *constraint) {
1247
1239
// side of a one-way binding.
1248
1240
auto firstType = constraint->getFirstType ();
1249
1241
if (auto *tv = firstType->getAs <TypeVariableType>()) {
1250
- if (tv->getImpl ().getRepresentative (nullptr ) == TypeVar)
1251
- return true ;
1242
+ if (tv->getImpl ().getRepresentative (nullptr ) == TypeVar) {
1243
+ DelayedBy.push_back (constraint);
1244
+ break ;
1245
+ }
1252
1246
}
1253
1247
1254
1248
break ;
1255
1249
}
1256
1250
}
1257
-
1258
- return false ;
1259
1251
}
1260
1252
1261
1253
LiteralBindingKind PotentialBindings::getLiteralKind () const {
0 commit comments