Skip to content

Commit cdf0bfb

Browse files
committed
[CS] Remove a couple uses of recordAnyTypeVarAsPotentialHole
It's not actually clear these are necessary anymore, and in one case it actually makes a diagnostic worse.
1 parent 782a5b4 commit cdf0bfb

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6683,12 +6683,6 @@ bool ConstraintSystem::repairFailures(
66836683
if (rhs->isExistentialType())
66846684
break;
66856685

6686-
// If the types didn't line up, let's allow right-hand side
6687-
// of the conversion (or pattern match) to have holes. This
6688-
// helps when conversion if between a type and a tuple e.g.
6689-
// `Int` vs. `(_, _)`.
6690-
recordAnyTypeVarAsPotentialHole(rhs);
6691-
66926686
conversionsOrFixes.push_back(CollectionElementContextualMismatch::create(
66936687
*this, lhs, rhs, getConstraintLocator(locator)));
66946688
break;
@@ -6782,9 +6776,6 @@ bool ConstraintSystem::repairFailures(
67826776

67836777
case ConstraintLocator::TernaryBranch:
67846778
case ConstraintLocator::SingleValueStmtResult: {
6785-
recordAnyTypeVarAsPotentialHole(lhs);
6786-
recordAnyTypeVarAsPotentialHole(rhs);
6787-
67886779
if (lhs->hasPlaceholder() || rhs->hasPlaceholder())
67896780
return true;
67906781

@@ -6852,8 +6843,6 @@ bool ConstraintSystem::repairFailures(
68526843
return true;
68536844

68546845
if (isMemberMatch) {
6855-
recordAnyTypeVarAsPotentialHole(lhs);
6856-
recordAnyTypeVarAsPotentialHole(rhs);
68576846
conversionsOrFixes.push_back(AllowAssociatedValueMismatch::create(
68586847
*this, lhs, rhs, getConstraintLocator(locator)));
68596848
break;

validation-test/Sema/type_checker_crashers_fixed/issue-65360.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ let _: () -> Void = {
99

1010
let _: () -> Void = {
1111
for case (0)? in [a] {}
12-
// expected-error@-1 {{pattern cannot match values of type 'Any?'}}
12+
// expected-error@-1 {{cannot convert sequence element type 'Any?' to expected type 'Int?'}}
1313
if case (0, 0) = a {}
1414
}
1515

1616
let _: () -> Void = {
1717
for case (0)? in [a] {}
18-
// expected-error@-1 {{pattern cannot match values of type 'Any?'}}
18+
// expected-error@-1 {{cannot convert sequence element type 'Any?' to expected type 'Int?'}}
1919
for case (0, 0) in [a] {}
2020
}
2121

0 commit comments

Comments
 (0)