@@ -142,37 +142,6 @@ ConstraintSystem::getPotentialBindings(TypeVariableType *typeVar) {
142
142
typeVar, constraints, ConstraintGraph::GatheringKind::EquivalenceClass);
143
143
144
144
PotentialBindings result;
145
- Optional<unsigned > lastSupertypeIndex;
146
-
147
- // Local function to add a potential binding to the list of bindings,
148
- // coalescing supertype bounds when we are able to compute the meet.
149
- auto addPotentialBinding = [&](PotentialBinding binding,
150
- bool allowJoinMeet = true ) {
151
- assert (!binding.BindingType ->is <ErrorType>());
152
- // If this is a non-defaulted supertype binding, check whether we can
153
- // combine it with another supertype binding by computing the 'join' of the
154
- // types.
155
- if (binding.Kind == AllowedBindingKind::Supertypes &&
156
- !binding.BindingType ->hasTypeVariable () && !binding.DefaultedProtocol &&
157
- !binding.isDefaultableBinding () && allowJoinMeet) {
158
- if (lastSupertypeIndex) {
159
- // Can we compute a join?
160
- auto &lastBinding = result.Bindings [*lastSupertypeIndex];
161
- auto lastType = lastBinding.BindingType ->getWithoutSpecifierType ();
162
- auto bindingType = binding.BindingType ->getWithoutSpecifierType ();
163
- if (auto join = Type::join (lastType, bindingType)) {
164
- // Replace the last supertype binding with the join. We're done.
165
- lastBinding.BindingType = join;
166
- return ;
167
- }
168
- }
169
-
170
- // Record this as the most recent supertype index.
171
- lastSupertypeIndex = result.Bindings .size ();
172
- }
173
-
174
- result.Bindings .push_back (std::move (binding));
175
- };
176
145
177
146
// Consider each of the constraints related to this type variable.
178
147
llvm::SmallPtrSet<CanType, 4 > exactTypes;
@@ -284,8 +253,8 @@ ConstraintSystem::getPotentialBindings(TypeVariableType *typeVar) {
284
253
continue ;
285
254
286
255
result.foundLiteralBinding (constraint->getProtocol ());
287
- addPotentialBinding ({defaultType, AllowedBindingKind::Subtypes,
288
- constraint->getProtocol ()});
256
+ result. addPotentialBinding ({defaultType, AllowedBindingKind::Subtypes,
257
+ constraint->getProtocol ()});
289
258
continue ;
290
259
}
291
260
@@ -311,8 +280,8 @@ ConstraintSystem::getPotentialBindings(TypeVariableType *typeVar) {
311
280
if (!matched) {
312
281
result.foundLiteralBinding (constraint->getProtocol ());
313
282
exactTypes.insert (defaultType->getCanonicalType ());
314
- addPotentialBinding ({defaultType, AllowedBindingKind::Subtypes,
315
- constraint->getProtocol ()});
283
+ result. addPotentialBinding ({defaultType, AllowedBindingKind::Subtypes,
284
+ constraint->getProtocol ()});
316
285
}
317
286
318
287
continue ;
@@ -484,10 +453,12 @@ ConstraintSystem::getPotentialBindings(TypeVariableType *typeVar) {
484
453
}
485
454
486
455
if (exactTypes.insert (type->getCanonicalType ()).second )
487
- addPotentialBinding ({type, kind, None}, /* allowJoinMeet=*/ !adjustedIUO);
456
+ result.addPotentialBinding ({type, kind, None},
457
+ /* allowJoinMeet=*/ !adjustedIUO);
488
458
if (alternateType &&
489
459
exactTypes.insert (alternateType->getCanonicalType ()).second )
490
- addPotentialBinding ({alternateType, kind, None}, /* allowJoinMeet=*/ false );
460
+ result.addPotentialBinding ({alternateType, kind, None},
461
+ /* allowJoinMeet=*/ false );
491
462
}
492
463
493
464
// If we have any literal constraints, check whether there is already a
@@ -565,7 +536,7 @@ ConstraintSystem::getPotentialBindings(TypeVariableType *typeVar) {
565
536
continue ;
566
537
567
538
++result.NumDefaultableBindings ;
568
- addPotentialBinding (
539
+ result. addPotentialBinding (
569
540
{type, AllowedBindingKind::Exact, None, constraint->getLocator ()});
570
541
}
571
542
0 commit comments