Skip to content

Commit cac98f3

Browse files
authored
Merge pull request swiftlang#84142 from hamishknight/for-none
[CS] NFC: Remove `CTP_ForEachStmt`
2 parents 92352b8 + 71d825d commit cac98f3

File tree

6 files changed

+3
-16
lines changed

6 files changed

+3
-16
lines changed

include/swift/Sema/ConstraintLocator.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,7 @@ enum ContextualTypePurpose : uint8_t {
7676
CTP_CaseStmt, ///< A single case statement associated with a `switch` or
7777
/// a `do-catch` statement. It has to be convertible
7878
/// to a type of a switch subject or an `Error` type.
79-
CTP_ForEachStmt, ///< "expression/sequence" associated with 'for-in' loop
80-
///< is expected to conform to 'Sequence' protocol.
81-
CTP_ForEachSequence, ///< Sequence expression associated with `for-in` loop,
82-
/// this element acts slightly differently compared to
83-
/// \c CTP_ForEachStmt in a sence that it would
84-
/// produce conformance constraints.
79+
CTP_ForEachSequence, ///< Sequence expression associated with `for-in` loop.
8580
CTP_WrappedProperty, ///< Property type expected to match 'wrappedValue' type
8681
CTP_ComposedPropertyWrapper, ///< Composed wrapper type expected to match
8782
///< former 'wrappedValue' type

include/swift/Sema/SyntacticElementTarget.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,6 @@ class SyntacticElementTarget {
601601

602602
switch (getExprContextualTypePurpose()) {
603603
case CTP_Initialization:
604-
case CTP_ForEachStmt:
605604
case CTP_ForEachSequence:
606605
case CTP_ExprPattern:
607606
break;

lib/Sema/CSApply.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9783,7 +9783,6 @@ ExprWalker::rewriteTarget(SyntacticElementTarget target) {
97839783
case CTP_CaseStmt:
97849784
case CTP_ReturnStmt:
97859785
case CTP_ExprPattern:
9786-
case CTP_ForEachStmt:
97879786
case CTP_ForEachSequence:
97889787
case CTP_YieldByValue:
97899788
case CTP_YieldByReference:

lib/Sema/CSDiagnostics.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,6 @@ GenericArgumentsMismatchFailure::getDiagnosticFor(
884884

885885
case CTP_CaseStmt:
886886
case CTP_ThrowStmt:
887-
case CTP_ForEachStmt:
888887
case CTP_ForEachSequence:
889888
case CTP_ComposedPropertyWrapper:
890889
case CTP_Unused:
@@ -2787,7 +2786,7 @@ bool ContextualFailure::diagnoseAsError() {
27872786
}
27882787
}
27892788

2790-
if (CTP == CTP_ForEachStmt || CTP == CTP_ForEachSequence) {
2789+
if (CTP == CTP_ForEachSequence) {
27912790
if (fromType->isAnyExistentialType()) {
27922791
Type constraintType = fromType;
27932792
if (auto existential = constraintType->getAs<ExistentialType>())
@@ -2986,7 +2985,6 @@ getContextualNilDiagnostic(ContextualTypePurpose CTP) {
29862985
case CTP_CaseStmt:
29872986
case CTP_ThrowStmt:
29882987
case CTP_DiscardStmt:
2989-
case CTP_ForEachStmt:
29902988
case CTP_ForEachSequence:
29912989
case CTP_YieldByReference:
29922990
case CTP_WrappedProperty:
@@ -3774,7 +3772,6 @@ ContextualFailure::getDiagnosticFor(ContextualTypePurpose context,
37743772
return diag::cannot_match_value_with_pattern;
37753773

37763774
case CTP_ThrowStmt:
3777-
case CTP_ForEachStmt:
37783775
case CTP_ForEachSequence:
37793776
case CTP_ComposedPropertyWrapper:
37803777
case CTP_Unused:
@@ -6610,8 +6607,7 @@ bool CollectionElementContextualFailure::diagnoseAsError() {
66106607
// If this is a conversion failure related to binding of `for-each`
66116608
// statement it has to be diagnosed as pattern match if there are
66126609
// holes present in the contextual type.
6613-
if ((purpose == ContextualTypePurpose::CTP_ForEachStmt ||
6614-
purpose == ContextualTypePurpose::CTP_ForEachSequence) &&
6610+
if (purpose == ContextualTypePurpose::CTP_ForEachSequence &&
66156611
contextualType->hasUnresolvedType()) {
66166612
auto diagnostic = emitDiagnostic(
66176613
(contextualType->is<TupleType>() && !eltType->is<TupleType>())

lib/Sema/CSSimplify.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16550,7 +16550,6 @@ void ConstraintSystem::addContextualConversionConstraint(
1655016550
case CTP_DictionaryValue:
1655116551
case CTP_CoerceOperand:
1655216552
case CTP_SubscriptAssignSource:
16553-
case CTP_ForEachStmt:
1655416553
case CTP_WrappedProperty:
1655516554
case CTP_ComposedPropertyWrapper:
1655616555
case CTP_ExprPattern:

lib/Sema/SyntacticElementTarget.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ bool SyntacticElementTarget::contextualTypeIsOnlyAHint() const {
261261
switch (getExprContextualTypePurpose()) {
262262
case CTP_Initialization:
263263
return !infersOpaqueReturnType() && !isOptionalSomePatternInit();
264-
case CTP_ForEachStmt:
265264
case CTP_ForEachSequence:
266265
return true;
267266
case CTP_Unused:

0 commit comments

Comments
 (0)