mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Revert "Sema: Remove ConstraintKind::OneWayEqual"
This reverts commit 385d66f24e.
This commit is contained in:
@@ -2183,6 +2183,7 @@ ConstraintSystem::matchTupleTypes(TupleType *tuple1, TupleType *tuple2,
|
||||
case ConstraintKind::ValueMember:
|
||||
case ConstraintKind::ValueWitness:
|
||||
case ConstraintKind::BridgingConversion:
|
||||
case ConstraintKind::OneWayEqual:
|
||||
case ConstraintKind::FallbackType:
|
||||
case ConstraintKind::UnresolvedMemberChainBase:
|
||||
case ConstraintKind::PropertyWrapper:
|
||||
@@ -2544,6 +2545,7 @@ static bool matchFunctionRepresentations(FunctionType::ExtInfo einfo1,
|
||||
case ConstraintKind::UnresolvedValueMember:
|
||||
case ConstraintKind::ValueMember:
|
||||
case ConstraintKind::ValueWitness:
|
||||
case ConstraintKind::OneWayEqual:
|
||||
case ConstraintKind::FallbackType:
|
||||
case ConstraintKind::UnresolvedMemberChainBase:
|
||||
case ConstraintKind::PropertyWrapper:
|
||||
@@ -3187,6 +3189,7 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
|
||||
case ConstraintKind::ValueMember:
|
||||
case ConstraintKind::ValueWitness:
|
||||
case ConstraintKind::BridgingConversion:
|
||||
case ConstraintKind::OneWayEqual:
|
||||
case ConstraintKind::FallbackType:
|
||||
case ConstraintKind::UnresolvedMemberChainBase:
|
||||
case ConstraintKind::PropertyWrapper:
|
||||
@@ -7128,6 +7131,7 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
|
||||
case ConstraintKind::UnresolvedValueMember:
|
||||
case ConstraintKind::ValueMember:
|
||||
case ConstraintKind::ValueWitness:
|
||||
case ConstraintKind::OneWayEqual:
|
||||
case ConstraintKind::FallbackType:
|
||||
case ConstraintKind::UnresolvedMemberChainBase:
|
||||
case ConstraintKind::PropertyWrapper:
|
||||
@@ -11608,6 +11612,38 @@ ConstraintSystem::simplifyPropertyWrapperConstraint(
|
||||
return SolutionKind::Solved;
|
||||
}
|
||||
|
||||
ConstraintSystem::SolutionKind
|
||||
ConstraintSystem::simplifyOneWayConstraint(
|
||||
ConstraintKind kind,
|
||||
Type first, Type second, TypeMatchOptions flags,
|
||||
ConstraintLocatorBuilder locator) {
|
||||
// Determine whether the second type can be fully simplified. Only then
|
||||
// will this constraint be resolved.
|
||||
Type secondSimplified = simplifyType(second);
|
||||
if (secondSimplified->hasTypeVariable()) {
|
||||
if (flags.contains(TMF_GenerateConstraints)) {
|
||||
addUnsolvedConstraint(
|
||||
Constraint::create(*this, kind, first, second,
|
||||
getConstraintLocator(locator)));
|
||||
return SolutionKind::Solved;
|
||||
}
|
||||
|
||||
return SolutionKind::Unsolved;
|
||||
}
|
||||
|
||||
// Propagate holes through one-way constraints.
|
||||
if (secondSimplified->isPlaceholder()) {
|
||||
recordAnyTypeVarAsPotentialHole(first);
|
||||
return SolutionKind::Solved;
|
||||
}
|
||||
|
||||
// Translate this constraint into an equality or bind-parameter constraint,
|
||||
// as appropriate.
|
||||
ASSERT(kind == ConstraintKind::OneWayEqual);
|
||||
return matchTypes(first, secondSimplified, ConstraintKind::Equal, flags,
|
||||
locator);
|
||||
}
|
||||
|
||||
ConstraintSystem::SolutionKind
|
||||
ConstraintSystem::simplifyUnresolvedMemberChainBaseConstraint(
|
||||
Type first, Type second, TypeMatchOptions flags,
|
||||
@@ -15685,6 +15721,9 @@ ConstraintSystem::addConstraintImpl(ConstraintKind kind, Type first,
|
||||
case ConstraintKind::PropertyWrapper:
|
||||
return simplifyPropertyWrapperConstraint(first, second, subflags, locator);
|
||||
|
||||
case ConstraintKind::OneWayEqual:
|
||||
return simplifyOneWayConstraint(kind, first, second, subflags, locator);
|
||||
|
||||
case ConstraintKind::UnresolvedMemberChainBase:
|
||||
return simplifyUnresolvedMemberChainBaseConstraint(first, second, subflags,
|
||||
locator);
|
||||
@@ -16262,6 +16301,12 @@ ConstraintSystem::simplifyConstraint(const Constraint &constraint) {
|
||||
// See {Dis, Con}junctionStep class in CSStep.cpp for solving
|
||||
return SolutionKind::Unsolved;
|
||||
|
||||
case ConstraintKind::OneWayEqual:
|
||||
return simplifyOneWayConstraint(
|
||||
constraint.getKind(), constraint.getFirstType(),
|
||||
constraint.getSecondType(),
|
||||
/*flags*/ std::nullopt, constraint.getLocator());
|
||||
|
||||
case ConstraintKind::UnresolvedMemberChainBase:
|
||||
return simplifyUnresolvedMemberChainBaseConstraint(
|
||||
constraint.getFirstType(), constraint.getSecondType(),
|
||||
|
||||
Reference in New Issue
Block a user