mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Sema: Special-case recording of Bind constraint in PreparedOverload
This commit is contained in:
@@ -71,6 +71,9 @@ struct PreparedOverloadChange {
|
||||
/// A generic requirement was opened to a constraint.
|
||||
AddedConstraint,
|
||||
|
||||
/// Special case of a Bind constraint.
|
||||
AddedBindConstraint,
|
||||
|
||||
/// A mapping of generic parameter types to type variables
|
||||
/// was recorded.
|
||||
OpenedTypes,
|
||||
@@ -98,6 +101,11 @@ struct PreparedOverloadChange {
|
||||
/// For ChangeKind::AddedConstraint.
|
||||
Constraint *TheConstraint;
|
||||
|
||||
struct {
|
||||
TypeBase *FirstType;
|
||||
TypeBase * SecondType;
|
||||
} Bind;
|
||||
|
||||
/// For ChangeKind::OpenedTypes.
|
||||
struct {
|
||||
const OpenedType *Data;
|
||||
@@ -192,6 +200,14 @@ struct PreparedOverloadBuilder {
|
||||
Changes.push_back(change);
|
||||
}
|
||||
|
||||
void addedBindConstraint(Type firstType, Type secondType) {
|
||||
PreparedOverload::Change change;
|
||||
change.Kind = PreparedOverload::Change::AddedBindConstraint;
|
||||
change.Bind.FirstType = firstType.getPointer();
|
||||
change.Bind.SecondType = secondType.getPointer();
|
||||
Changes.push_back(change);
|
||||
}
|
||||
|
||||
void openedTypes(ArrayRef<OpenedType> replacements) {
|
||||
PreparedOverload::Change change;
|
||||
change.Kind = PreparedOverload::Change::OpenedTypes;
|
||||
|
||||
@@ -16365,6 +16365,11 @@ void ConstraintSystem::addConstraint(ConstraintKind kind, Type first,
|
||||
PreparedOverloadBuilder *preparedOverload) {
|
||||
if (preparedOverload) {
|
||||
ASSERT(PreparingOverload);
|
||||
if (kind == ConstraintKind::Bind) {
|
||||
ASSERT(!isFavored);
|
||||
preparedOverload->addedBindConstraint(first, second);
|
||||
return;
|
||||
}
|
||||
auto c = Constraint::create(*this, kind, first, second,
|
||||
getConstraintLocator(locator));
|
||||
if (isFavored) c->setFavored();
|
||||
|
||||
@@ -2510,6 +2510,13 @@ void ConstraintSystem::replayChanges(
|
||||
simplifyDisjunctionChoice(change.TheConstraint);
|
||||
break;
|
||||
|
||||
case PreparedOverload::Change::AddedBindConstraint:
|
||||
addConstraint(ConstraintKind::Bind,
|
||||
change.Bind.FirstType,
|
||||
change.Bind.SecondType,
|
||||
locator, /*isFavored=*/false);
|
||||
break;
|
||||
|
||||
case PreparedOverload::Change::OpenedTypes: {
|
||||
ArrayRef<OpenedType> replacements(
|
||||
change.Replacements.Data,
|
||||
|
||||
Reference in New Issue
Block a user