diff --git a/include/swift/Sema/ConstraintLocator.h b/include/swift/Sema/ConstraintLocator.h index e1ed7f2d20a4c..3b6052e6df2ef 100644 --- a/include/swift/Sema/ConstraintLocator.h +++ b/include/swift/Sema/ConstraintLocator.h @@ -76,12 +76,7 @@ enum ContextualTypePurpose : uint8_t { CTP_CaseStmt, ///< A single case statement associated with a `switch` or /// a `do-catch` statement. It has to be convertible /// to a type of a switch subject or an `Error` type. - CTP_ForEachStmt, ///< "expression/sequence" associated with 'for-in' loop - ///< is expected to conform to 'Sequence' protocol. - CTP_ForEachSequence, ///< Sequence expression associated with `for-in` loop, - /// this element acts slightly differently compared to - /// \c CTP_ForEachStmt in a sence that it would - /// produce conformance constraints. + CTP_ForEachSequence, ///< Sequence expression associated with `for-in` loop. CTP_WrappedProperty, ///< Property type expected to match 'wrappedValue' type CTP_ComposedPropertyWrapper, ///< Composed wrapper type expected to match ///< former 'wrappedValue' type diff --git a/include/swift/Sema/SyntacticElementTarget.h b/include/swift/Sema/SyntacticElementTarget.h index 9650e2d1b9240..674a429ccf7b8 100644 --- a/include/swift/Sema/SyntacticElementTarget.h +++ b/include/swift/Sema/SyntacticElementTarget.h @@ -601,7 +601,6 @@ class SyntacticElementTarget { switch (getExprContextualTypePurpose()) { case CTP_Initialization: - case CTP_ForEachStmt: case CTP_ForEachSequence: case CTP_ExprPattern: break; diff --git a/lib/Sema/CSApply.cpp b/lib/Sema/CSApply.cpp index 8b2802ddd9487..dae33e9c070ed 100644 --- a/lib/Sema/CSApply.cpp +++ b/lib/Sema/CSApply.cpp @@ -9723,7 +9723,6 @@ ExprWalker::rewriteTarget(SyntacticElementTarget target) { case CTP_CaseStmt: case CTP_ReturnStmt: case CTP_ExprPattern: - case CTP_ForEachStmt: case CTP_ForEachSequence: case CTP_YieldByValue: case CTP_YieldByReference: diff --git a/lib/Sema/CSDiagnostics.cpp b/lib/Sema/CSDiagnostics.cpp index 95b1ad4ce7feb..2537b927ec2e2 100644 --- a/lib/Sema/CSDiagnostics.cpp +++ b/lib/Sema/CSDiagnostics.cpp @@ -884,7 +884,6 @@ GenericArgumentsMismatchFailure::getDiagnosticFor( case CTP_CaseStmt: case CTP_ThrowStmt: - case CTP_ForEachStmt: case CTP_ForEachSequence: case CTP_ComposedPropertyWrapper: case CTP_Unused: @@ -2787,7 +2786,7 @@ bool ContextualFailure::diagnoseAsError() { } } - if (CTP == CTP_ForEachStmt || CTP == CTP_ForEachSequence) { + if (CTP == CTP_ForEachSequence) { if (fromType->isAnyExistentialType()) { Type constraintType = fromType; if (auto existential = constraintType->getAs()) @@ -2986,7 +2985,6 @@ getContextualNilDiagnostic(ContextualTypePurpose CTP) { case CTP_CaseStmt: case CTP_ThrowStmt: case CTP_DiscardStmt: - case CTP_ForEachStmt: case CTP_ForEachSequence: case CTP_YieldByReference: case CTP_WrappedProperty: @@ -3774,7 +3772,6 @@ ContextualFailure::getDiagnosticFor(ContextualTypePurpose context, return diag::cannot_match_value_with_pattern; case CTP_ThrowStmt: - case CTP_ForEachStmt: case CTP_ForEachSequence: case CTP_ComposedPropertyWrapper: case CTP_Unused: @@ -6610,8 +6607,7 @@ bool CollectionElementContextualFailure::diagnoseAsError() { // If this is a conversion failure related to binding of `for-each` // statement it has to be diagnosed as pattern match if there are // holes present in the contextual type. - if ((purpose == ContextualTypePurpose::CTP_ForEachStmt || - purpose == ContextualTypePurpose::CTP_ForEachSequence) && + if (purpose == ContextualTypePurpose::CTP_ForEachSequence && contextualType->hasUnresolvedType()) { auto diagnostic = emitDiagnostic( (contextualType->is() && !eltType->is()) diff --git a/lib/Sema/CSSimplify.cpp b/lib/Sema/CSSimplify.cpp index 98830de3d0a64..00fce0f20f5f2 100644 --- a/lib/Sema/CSSimplify.cpp +++ b/lib/Sema/CSSimplify.cpp @@ -16550,7 +16550,6 @@ void ConstraintSystem::addContextualConversionConstraint( case CTP_DictionaryValue: case CTP_CoerceOperand: case CTP_SubscriptAssignSource: - case CTP_ForEachStmt: case CTP_WrappedProperty: case CTP_ComposedPropertyWrapper: case CTP_ExprPattern: diff --git a/lib/Sema/SyntacticElementTarget.cpp b/lib/Sema/SyntacticElementTarget.cpp index e40eff45bc58a..60b53dc60b8e2 100644 --- a/lib/Sema/SyntacticElementTarget.cpp +++ b/lib/Sema/SyntacticElementTarget.cpp @@ -261,7 +261,6 @@ bool SyntacticElementTarget::contextualTypeIsOnlyAHint() const { switch (getExprContextualTypePurpose()) { case CTP_Initialization: return !infersOpaqueReturnType() && !isOptionalSomePatternInit(); - case CTP_ForEachStmt: case CTP_ForEachSequence: return true; case CTP_Unused: