Skip to content

Commit 1026968

Browse files
committed
Sema: Remove ConversionRestrictionKind::TupleToTuple
1 parent 28343c9 commit 1026968

File tree

4 files changed

+10
-32
lines changed

4 files changed

+10
-32
lines changed

lib/Sema/CSApply.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6367,12 +6367,6 @@ Expr *ExprRewriter::coerceToType(Expr *expr, Type toType,
63676367
toType->getCanonicalType() });
63686368
if (knownRestriction != solution.ConstraintRestrictions.end()) {
63696369
switch (knownRestriction->second) {
6370-
6371-
case ConversionRestrictionKind::TupleToTuple:
6372-
// Restrictions that don't need to be recorded.
6373-
// Should match recordRestriction() in CSSimplify
6374-
break;
6375-
63766370
case ConversionRestrictionKind::DeepEquality: {
63776371
if (toType->hasUnresolvedType())
63786372
break;

lib/Sema/CSSimplify.cpp

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,10 +1877,15 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
18771877
return getTypeMatchFailure(locator);
18781878

18791879
case TypeKind::Tuple: {
1880-
assert(!type2->is<LValueType>() && "Unexpected lvalue type!");
1881-
// Try the tuple-to-tuple conversion.
1882-
if (!type1->is<LValueType>())
1883-
conversionsOrFixes.push_back(ConversionRestrictionKind::TupleToTuple);
1880+
auto result = matchTupleTypes(cast<TupleType>(desugar1),
1881+
cast<TupleType>(desugar2),
1882+
kind, subflags, locator);
1883+
if (result != SolutionKind::Error)
1884+
return result;
1885+
1886+
// FIXME: All cases in this switch should go down to the fix logic
1887+
// to give repairFailures() a chance to run, but this breaks stuff
1888+
// right now.
18841889
break;
18851890
}
18861891

@@ -4943,11 +4948,6 @@ ConstraintSystem::simplifyRestrictedConstraintImpl(
49434948
switch (restriction) {
49444949
// for $< in { <, <c, <oc }:
49454950
// T_i $< U_i ===> (T_i...) $< (U_i...)
4946-
case ConversionRestrictionKind::TupleToTuple:
4947-
return matchTupleTypes(type1->castTo<TupleType>(),
4948-
type2->castTo<TupleType>(),
4949-
matchKind, subflags, locator);
4950-
49514951
case ConversionRestrictionKind::DeepEquality:
49524952
return matchDeepEqualityTypes(type1, type2, locator);
49534953

@@ -5269,17 +5269,6 @@ ConstraintSystem::simplifyRestrictedConstraintImpl(
52695269
llvm_unreachable("bad conversion restriction");
52705270
}
52715271

5272-
// Restrictions where CSApply can figure out the correct action from the shape of
5273-
// the types, rather than needing a record of the choice made.
5274-
static bool recordRestriction(ConversionRestrictionKind restriction) {
5275-
switch(restriction) {
5276-
case ConversionRestrictionKind::TupleToTuple:
5277-
return false;
5278-
default:
5279-
return true;
5280-
}
5281-
}
5282-
52835272
ConstraintSystem::SolutionKind
52845273
ConstraintSystem::simplifyRestrictedConstraint(
52855274
ConversionRestrictionKind restriction,
@@ -5290,8 +5279,7 @@ ConstraintSystem::simplifyRestrictedConstraint(
52905279
switch (simplifyRestrictedConstraintImpl(restriction, type1, type2,
52915280
matchKind, flags, locator)) {
52925281
case SolutionKind::Solved:
5293-
if (recordRestriction(restriction))
5294-
ConstraintRestrictions.push_back(std::make_tuple(type1, type2, restriction));
5282+
ConstraintRestrictions.push_back(std::make_tuple(type1, type2, restriction));
52955283
return SolutionKind::Solved;
52965284

52975285
case SolutionKind::Unsolved:

lib/Sema/Constraint.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,6 @@ void Constraint::dump(ConstraintSystem *CS) const {
428428

429429
StringRef swift::constraints::getName(ConversionRestrictionKind kind) {
430430
switch (kind) {
431-
case ConversionRestrictionKind::TupleToTuple:
432-
return "[tuple-to-tuple]";
433431
case ConversionRestrictionKind::DeepEquality:
434432
return "[deep equality]";
435433
case ConversionRestrictionKind::Superclass:

lib/Sema/Constraint.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,6 @@ enum class ConstraintClassification : char {
174174
/// a superclass conversion from A to B or there might be a user-defined
175175
/// conversion from A to B. The solver may need to explore both paths.
176176
enum class ConversionRestrictionKind {
177-
/// Tuple-to-tuple conversion.
178-
TupleToTuple,
179177
/// Deep equality comparison.
180178
DeepEquality,
181179
/// Subclass-to-superclass conversion.

0 commit comments

Comments
 (0)