@@ -4527,60 +4527,8 @@ class ConstraintSystem {
4527
4527
// Build a disjunction that attempts both T? and T for a particular
4528
4528
// type binding. The choice of T? is preferred, and we will not
4529
4529
// attempt T if we can type check with T?
4530
- void
4531
- buildDisjunctionForOptionalVsUnderlying (Type boundTy, Type type,
4532
- ConstraintLocator *locator) {
4533
- // NOTE: If we use other locator kinds for these disjunctions, we
4534
- // need to account for it in solution scores for forced-unwraps.
4535
- assert (locator->getPath ().back ().getKind () ==
4536
- ConstraintLocator::ImplicitlyUnwrappedDisjunctionChoice ||
4537
- locator->getPath ().back ().getKind () ==
4538
- ConstraintLocator::DynamicLookupResult);
4539
-
4540
- // Create the constraint to bind to the optional type and make it
4541
- // the favored choice.
4542
- auto *bindToOptional =
4543
- Constraint::create (*this , ConstraintKind::Bind, boundTy, type, locator);
4544
- bindToOptional->setFavored ();
4545
-
4546
- Type underlyingType;
4547
- if (auto *fnTy = type->getAs <AnyFunctionType>())
4548
- underlyingType = replaceFinalResultTypeWithUnderlying (fnTy);
4549
- else if (auto *typeVar =
4550
- type->getWithoutSpecifierType ()->getAs <TypeVariableType>()) {
4551
- auto *locator = typeVar->getImpl ().getLocator ();
4552
-
4553
- // If `type` hasn't been resolved yet, we need to allocate a type
4554
- // variable to represent an object type of a future optional, and
4555
- // add a constraint beetween `type` and `underlyingType` to model it.
4556
- underlyingType = createTypeVariable (
4557
- getConstraintLocator (locator, LocatorPathElt::GenericArgument (0 )),
4558
- TVO_PrefersSubtypeBinding | TVO_CanBindToLValue |
4559
- TVO_CanBindToNoEscape);
4560
-
4561
- // Using a `typeVar` here because l-value is going to be applied
4562
- // to the underlying type below.
4563
- addConstraint (ConstraintKind::OptionalObject, typeVar, underlyingType,
4564
- locator);
4565
- } else {
4566
- underlyingType = type->getWithoutSpecifierType ()->getOptionalObjectType ();
4567
- }
4568
-
4569
- assert (underlyingType);
4570
-
4571
- if (type->is <LValueType>())
4572
- underlyingType = LValueType::get (underlyingType);
4573
- assert (!type->is <InOutType>());
4574
-
4575
- auto *bindToUnderlying = Constraint::create (
4576
- *this , ConstraintKind::Bind, boundTy, underlyingType, locator);
4577
-
4578
- llvm::SmallVector<Constraint *, 2 > choices = {bindToOptional,
4579
- bindToUnderlying};
4580
-
4581
- // Create the disjunction
4582
- addDisjunctionConstraint (choices, locator, RememberChoice);
4583
- }
4530
+ void buildDisjunctionForOptionalVsUnderlying (Type boundTy, Type ty,
4531
+ ConstraintLocator *locator);
4584
4532
4585
4533
// Build a disjunction for types declared IUO.
4586
4534
void
0 commit comments