|
40 | 40 | #include "swift/Sema/CSFix.h" |
41 | 41 | #include "swift/Sema/ConstraintSystem.h" |
42 | 42 | #include "swift/Sema/IDETypeChecking.h" |
| 43 | +#include "swift/Sema/PreparedOverload.h" |
43 | 44 | #include "llvm/ADT/SetVector.h" |
44 | 45 | #include "llvm/Support/Compiler.h" |
45 | 46 |
|
@@ -16269,15 +16270,17 @@ ConstraintSystem::addKeyPathConstraint( |
16269 | 16270 | void ConstraintSystem::addConstraint(Requirement req, |
16270 | 16271 | ConstraintLocatorBuilder locator, |
16271 | 16272 | bool isFavored, |
16272 | | - bool prohibitNonisolatedConformance) { |
| 16273 | + bool prohibitNonisolatedConformance, |
| 16274 | + PreparedOverload *preparedOverload) { |
16273 | 16275 | bool conformsToAnyObject = false; |
16274 | 16276 | std::optional<ConstraintKind> kind; |
16275 | 16277 | switch (req.getKind()) { |
16276 | 16278 | case RequirementKind::SameShape: { |
16277 | 16279 | auto type1 = req.getFirstType(); |
16278 | 16280 | auto type2 = req.getSecondType(); |
16279 | 16281 |
|
16280 | | - addConstraint(ConstraintKind::SameShape, type1, type2, locator); |
| 16282 | + addConstraint(ConstraintKind::SameShape, type1, type2, locator, |
| 16283 | + /*isFavored=*/false, preparedOverload); |
16281 | 16284 | return; |
16282 | 16285 | } |
16283 | 16286 |
|
@@ -16318,19 +16321,32 @@ void ConstraintSystem::addConstraint(Requirement req, |
16318 | 16321 | auto firstType = req.getFirstType(); |
16319 | 16322 | if (kind) { |
16320 | 16323 | addConstraint(*kind, req.getFirstType(), req.getSecondType(), locator, |
16321 | | - isFavored); |
| 16324 | + isFavored, preparedOverload); |
16322 | 16325 | } |
16323 | 16326 |
|
16324 | 16327 | if (conformsToAnyObject) { |
16325 | 16328 | auto anyObject = getASTContext().getAnyObjectConstraint(); |
16326 | | - addConstraint(ConstraintKind::ConformsTo, firstType, anyObject, locator); |
| 16329 | + addConstraint(ConstraintKind::ConformsTo, firstType, anyObject, locator, |
| 16330 | + /*isFavored=*/false, preparedOverload); |
16327 | 16331 | } |
16328 | 16332 | } |
16329 | 16333 |
|
16330 | 16334 | void ConstraintSystem::addConstraint(ConstraintKind kind, Type first, |
16331 | 16335 | Type second, |
16332 | 16336 | ConstraintLocatorBuilder locator, |
16333 | | - bool isFavored) { |
| 16337 | + bool isFavored, |
| 16338 | + PreparedOverload *preparedOverload) { |
| 16339 | + if (preparedOverload) { |
| 16340 | + ASSERT(PreparingOverload); |
| 16341 | + auto c = Constraint::create(*this, kind, first, second, |
| 16342 | + getConstraintLocator(locator)); |
| 16343 | + if (isFavored) c->setFavored(); |
| 16344 | + preparedOverload->Constraints.push_back(c); |
| 16345 | + return; |
| 16346 | + } |
| 16347 | + |
| 16348 | + ASSERT(!PreparingOverload); |
| 16349 | + |
16334 | 16350 | switch (addConstraintImpl(kind, first, second, locator, isFavored)) { |
16335 | 16351 | case SolutionKind::Error: |
16336 | 16352 | // Add a failing constraint, if needed. |
|
0 commit comments