Skip to content

Commit dab4616

Browse files
committed
Sema: simplifyRestrictedConstraintImpl() can't form unsolved constraints
1 parent 515ffe9 commit dab4616

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4922,6 +4922,8 @@ ConstraintSystem::simplifyRestrictedConstraintImpl(
49224922
ConstraintKind matchKind,
49234923
TypeMatchOptions flags,
49244924
ConstraintLocatorBuilder locator) {
4925+
assert(!type1->isTypeVariableOrMember() && !type2->isTypeVariableOrMember());
4926+
49254927
// Add to the score based on context.
49264928
auto addContextualScore = [&] {
49274929
// Okay, we need to perform one or more conversions. If this
@@ -4933,20 +4935,6 @@ ConstraintSystem::simplifyRestrictedConstraintImpl(
49334935
}
49344936
};
49354937

4936-
// Local function to form an unsolved result.
4937-
auto formUnsolved = [&] {
4938-
if (flags.contains(TMF_GenerateConstraints)) {
4939-
addUnsolvedConstraint(
4940-
Constraint::createRestricted(
4941-
*this, matchKind, restriction, type1, type2,
4942-
getConstraintLocator(locator)));
4943-
4944-
return SolutionKind::Solved;
4945-
}
4946-
4947-
return SolutionKind::Unsolved;
4948-
};
4949-
49504938
TypeMatchOptions subflags = getDefaultDecompositionOptions(flags);
49514939

49524940
switch (restriction) {
@@ -5019,9 +5007,6 @@ ConstraintSystem::simplifyRestrictedConstraintImpl(
50195007
increaseScore(SK_ValueToOptional);
50205008

50215009
assert(matchKind >= ConstraintKind::Subtype);
5022-
if (type2->isTypeVariableOrMember())
5023-
return formUnsolved();
5024-
50255010
if (auto generic2 = type2->getAs<BoundGenericType>()) {
50265011
if (generic2->getDecl()->isOptionalDecl()) {
50275012
return matchTypes(type1, generic2->getGenericArgs()[0],
@@ -5043,9 +5028,6 @@ ConstraintSystem::simplifyRestrictedConstraintImpl(
50435028
case ConversionRestrictionKind::OptionalToOptional: {
50445029
addContextualScore();
50455030

5046-
if (type1->isTypeVariableOrMember() || type2->isTypeVariableOrMember())
5047-
return formUnsolved();
5048-
50495031
assert(matchKind >= ConstraintKind::Subtype);
50505032
if (auto generic1 = type1->getAs<BoundGenericType>()) {
50515033
if (auto generic2 = type2->getAs<BoundGenericType>()) {

0 commit comments

Comments
 (0)