@@ -310,31 +310,27 @@ ConstraintSystem::getPotentialBindingForRelationalConstraint(
310
310
311
311
// Check whether we can perform this binding.
312
312
// FIXME: this has a super-inefficient extraneous simplifyType() in it.
313
- bool isNilLiteral = false ;
314
- bool *isNilLiteralPtr = nullptr ;
315
313
if (auto boundType = checkTypeOfBinding (typeVar, type)) {
316
314
type = *boundType;
317
315
if (type->hasTypeVariable ())
318
316
result.InvolvesTypeVariables = true ;
319
317
} else {
320
- if (!addOptionalSupertypeBindings && kind == AllowedBindingKind::Supertypes)
321
- isNilLiteralPtr = &isNilLiteral;
322
-
323
- if (isNilLiteralPtr) {
324
- if (auto *bindingTypeVar =
325
- type->getRValueType ()->getAs <TypeVariableType>())
326
- *isNilLiteralPtr = hasNilLiteralConstraint (bindingTypeVar, *this );
327
- else
328
- *isNilLiteralPtr = false ;
329
- }
318
+ auto *bindingTypeVar = type->getRValueType ()->getAs <TypeVariableType>();
330
319
331
- // If the bound is a 'nil' literal type, add optional supertype bindings.
332
- if (isNilLiteral) {
333
- addOptionalSupertypeBindings = true ;
320
+ if (!bindingTypeVar)
334
321
return None;
335
- }
336
322
337
323
result.InvolvesTypeVariables = true ;
324
+
325
+ // If we've already set addOptionalSupertypeBindings, or we aren't
326
+ // allowing supertype bindings, we're done.
327
+ if (addOptionalSupertypeBindings || kind != AllowedBindingKind::Supertypes)
328
+ return None;
329
+
330
+ // If the bound is a 'nil' literal type, add optional supertype bindings.
331
+ if (hasNilLiteralConstraint (bindingTypeVar, *this ))
332
+ addOptionalSupertypeBindings = true ;
333
+
338
334
return None;
339
335
}
340
336
0 commit comments