Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions include/swift/Sema/ConstraintLocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion include/swift/Sema/SyntacticElementTarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,6 @@ class SyntacticElementTarget {

switch (getExprContextualTypePurpose()) {
case CTP_Initialization:
case CTP_ForEachStmt:
case CTP_ForEachSequence:
case CTP_ExprPattern:
break;
Expand Down
1 change: 0 additions & 1 deletion lib/Sema/CSApply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 2 additions & 6 deletions lib/Sema/CSDiagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,6 @@ GenericArgumentsMismatchFailure::getDiagnosticFor(

case CTP_CaseStmt:
case CTP_ThrowStmt:
case CTP_ForEachStmt:
case CTP_ForEachSequence:
case CTP_ComposedPropertyWrapper:
case CTP_Unused:
Expand Down Expand Up @@ -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<ExistentialType>())
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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<TupleType>() && !eltType->is<TupleType>())
Expand Down
1 change: 0 additions & 1 deletion lib/Sema/CSSimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion lib/Sema/SyntacticElementTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down