mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Sema: Only use PreparedOverload::Change::AddedBindConstraint if the locator didn't change
For a Bind constraint generated by a same-type requirement, we must preserve the locator so we need to record it like any other kind of constraint. This fixes a diagnostic regression with -solver-enable-prepared-overloads.
This commit is contained in:
@@ -16529,14 +16529,22 @@ void ConstraintSystem::addConstraint(ConstraintKind kind, Type first,
|
||||
PreparedOverloadBuilder *preparedOverload) {
|
||||
if (preparedOverload) {
|
||||
ASSERT(PreparingOverload);
|
||||
if (kind == ConstraintKind::Bind) {
|
||||
|
||||
auto *locatorPtr = getConstraintLocator(locator);
|
||||
|
||||
// Fast path to save on memory usage.
|
||||
if (kind == ConstraintKind::Bind &&
|
||||
locatorPtr == preparedOverload->Locator) {
|
||||
ASSERT(!isFavored);
|
||||
preparedOverload->addedBindConstraint(first, second);
|
||||
return;
|
||||
}
|
||||
auto c = Constraint::create(*this, kind, first, second,
|
||||
getConstraintLocator(locator));
|
||||
if (isFavored) c->setFavored();
|
||||
|
||||
auto c = Constraint::create(*this, kind, first, second, locatorPtr);
|
||||
|
||||
if (isFavored)
|
||||
c->setFavored();
|
||||
|
||||
preparedOverload->addedConstraint(c);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user