From 6abfea9312d151faf997bd0b8d01384a623e49f4 Mon Sep 17 00:00:00 2001 From: Hamish Knight Date: Sun, 16 Nov 2025 18:17:39 +0000 Subject: [PATCH 1/2] [CS] NFC: Remove `CTP_CalleeResult` This has been unused since the removal of CSDiag. --- include/swift/Sema/ConstraintLocator.h | 1 - lib/Sema/CSApply.cpp | 1 - lib/Sema/CSDiagnostics.cpp | 5 ----- lib/Sema/CSSimplify.cpp | 1 - lib/Sema/SyntacticElementTarget.cpp | 1 - test/Migrator/Inputs/substring_to_string_conversion.swift | 2 +- test/Migrator/substring_to_string_conversion.swift.expected | 2 +- test/Sema/substring_to_string_conversion_swift4.swift | 2 +- 8 files changed, 3 insertions(+), 12 deletions(-) diff --git a/include/swift/Sema/ConstraintLocator.h b/include/swift/Sema/ConstraintLocator.h index 3b6052e6df2ef..6ece270ac6e2b 100644 --- a/include/swift/Sema/ConstraintLocator.h +++ b/include/swift/Sema/ConstraintLocator.h @@ -61,7 +61,6 @@ enum ContextualTypePurpose : uint8_t { /// 'foo(a : @autoclosure () -> Int = 42)'. CTP_AutoclosureDefaultParameter, - CTP_CalleeResult, ///< Constraint is placed on the result of a callee. CTP_CallArgument, ///< Call to function or operator requires type. CTP_ClosureResult, ///< Closure result expects a specific type. CTP_ArrayElement, ///< ArrayExpr wants elements to have a specific type. diff --git a/lib/Sema/CSApply.cpp b/lib/Sema/CSApply.cpp index 095bf58abd1b5..9cf6ce2ce3d5f 100644 --- a/lib/Sema/CSApply.cpp +++ b/lib/Sema/CSApply.cpp @@ -9606,7 +9606,6 @@ ExprWalker::rewriteTarget(SyntacticElementTarget target) { case CTP_EnumCaseRawValue: case CTP_DefaultParameter: case CTP_AutoclosureDefaultParameter: - case CTP_CalleeResult: case CTP_CallArgument: case CTP_ClosureResult: case CTP_ArrayElement: diff --git a/lib/Sema/CSDiagnostics.cpp b/lib/Sema/CSDiagnostics.cpp index a99a2eb0c7f0d..f878fa7b019c7 100644 --- a/lib/Sema/CSDiagnostics.cpp +++ b/lib/Sema/CSDiagnostics.cpp @@ -867,7 +867,6 @@ GenericArgumentsMismatchFailure::getDiagnosticFor( case CTP_Unused: case CTP_CannotFail: case CTP_YieldByReference: - case CTP_CalleeResult: case CTP_EnumCaseRawValue: case CTP_ExprPattern: case CTP_SingleValueStmtBranch: @@ -2954,9 +2953,6 @@ getContextualNilDiagnostic(ContextualTypePurpose CTP) { case CTP_CannotFail: llvm_unreachable("These contextual type purposes cannot fail with a " "conversion type specified!"); - case CTP_CalleeResult: - llvm_unreachable("CTP_CalleeResult does not actually install a " - "contextual type"); case CTP_Initialization: return diag::cannot_convert_initializer_value_nil; @@ -3758,7 +3754,6 @@ ContextualFailure::getDiagnosticFor(ContextualTypePurpose context, case CTP_Unused: case CTP_CannotFail: case CTP_YieldByReference: - case CTP_CalleeResult: case CTP_ExprPattern: break; } diff --git a/lib/Sema/CSSimplify.cpp b/lib/Sema/CSSimplify.cpp index 21797bc5454b7..c1e40a1568f8a 100644 --- a/lib/Sema/CSSimplify.cpp +++ b/lib/Sema/CSSimplify.cpp @@ -16696,7 +16696,6 @@ void ConstraintSystem::addContextualConversionConstraint( case CTP_ArrayElement: case CTP_AssignSource: - case CTP_CalleeResult: case CTP_CannotFail: case CTP_Condition: case CTP_Unused: diff --git a/lib/Sema/SyntacticElementTarget.cpp b/lib/Sema/SyntacticElementTarget.cpp index a23a7e281e343..88c3daec0a0c4 100644 --- a/lib/Sema/SyntacticElementTarget.cpp +++ b/lib/Sema/SyntacticElementTarget.cpp @@ -263,7 +263,6 @@ bool SyntacticElementTarget::contextualTypeIsOnlyAHint() const { case CTP_EnumCaseRawValue: case CTP_DefaultParameter: case CTP_AutoclosureDefaultParameter: - case CTP_CalleeResult: case CTP_CallArgument: case CTP_ClosureResult: case CTP_ArrayElement: diff --git a/test/Migrator/Inputs/substring_to_string_conversion.swift b/test/Migrator/Inputs/substring_to_string_conversion.swift index 3c969e1435279..5f8dc5134efb0 100644 --- a/test/Migrator/Inputs/substring_to_string_conversion.swift +++ b/test/Migrator/Inputs/substring_to_string_conversion.swift @@ -28,7 +28,7 @@ do { func foo(x: String = ss) {} } -// CTP_CalleeResult +// CTP_Initialization do { func getSubstring() -> Substring { return ss } let gottenString : String = getSubstring() diff --git a/test/Migrator/substring_to_string_conversion.swift.expected b/test/Migrator/substring_to_string_conversion.swift.expected index 8a2a547c3e6ae..e24c6b400b6db 100644 --- a/test/Migrator/substring_to_string_conversion.swift.expected +++ b/test/Migrator/substring_to_string_conversion.swift.expected @@ -28,7 +28,7 @@ do { func foo(x: String = String(ss)) {} } -// CTP_CalleeResult +// CTP_Initialization do { func getSubstring() -> Substring { return ss } let gottenString : String = String(getSubstring()) diff --git a/test/Sema/substring_to_string_conversion_swift4.swift b/test/Sema/substring_to_string_conversion_swift4.swift index 8f2725cc029e9..a2b5ede4e3e10 100644 --- a/test/Sema/substring_to_string_conversion_swift4.swift +++ b/test/Sema/substring_to_string_conversion_swift4.swift @@ -30,7 +30,7 @@ do { func foo(x: String = ss) {} // expected-error {{default argument value of type 'Substring' cannot be converted to type 'String'}} {{24-24=String(}} {{26-26=)}} } -// CTP_CalleeResult +// CTP_Initialization do { func getSubstring() -> Substring { return ss } let gottenString : String = getSubstring() // expected-error {{cannot convert value of type 'Substring' to specified type 'String'}} {{31-31=String(}} {{45-45=)}} From 9a31ef029c735c27f3b4fc822a5b64f518297662 Mon Sep 17 00:00:00 2001 From: Hamish Knight Date: Sun, 16 Nov 2025 18:28:56 +0000 Subject: [PATCH 2/2] [CS] NFC: Remove `CTP_ComposedPropertyWrapper` This has been unused since we added a custom `AllowWrappedValueMismatch` fix. --- include/swift/Sema/ConstraintLocator.h | 2 -- lib/Sema/CSApply.cpp | 1 - lib/Sema/CSDiagnostics.cpp | 3 --- lib/Sema/CSSimplify.cpp | 1 - lib/Sema/SyntacticElementTarget.cpp | 1 - 5 files changed, 8 deletions(-) diff --git a/include/swift/Sema/ConstraintLocator.h b/include/swift/Sema/ConstraintLocator.h index 6ece270ac6e2b..e520d02cff860 100644 --- a/include/swift/Sema/ConstraintLocator.h +++ b/include/swift/Sema/ConstraintLocator.h @@ -77,8 +77,6 @@ enum ContextualTypePurpose : uint8_t { /// to a type of a switch subject or an `Error` type. 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 CTP_SingleValueStmtBranch, ///< The contextual type for a branch in a single ///< value statement expression. diff --git a/lib/Sema/CSApply.cpp b/lib/Sema/CSApply.cpp index 9cf6ce2ce3d5f..e98e7d487afa0 100644 --- a/lib/Sema/CSApply.cpp +++ b/lib/Sema/CSApply.cpp @@ -9616,7 +9616,6 @@ ExprWalker::rewriteTarget(SyntacticElementTarget target) { case CTP_SubscriptAssignSource: case CTP_Condition: case CTP_WrappedProperty: - case CTP_ComposedPropertyWrapper: case CTP_CannotFail: case CTP_SingleValueStmtBranch: result.setExpr(rewrittenExpr); diff --git a/lib/Sema/CSDiagnostics.cpp b/lib/Sema/CSDiagnostics.cpp index f878fa7b019c7..f1fc205321ea4 100644 --- a/lib/Sema/CSDiagnostics.cpp +++ b/lib/Sema/CSDiagnostics.cpp @@ -863,7 +863,6 @@ GenericArgumentsMismatchFailure::getDiagnosticFor( case CTP_CaseStmt: case CTP_ThrowStmt: case CTP_ForEachSequence: - case CTP_ComposedPropertyWrapper: case CTP_Unused: case CTP_CannotFail: case CTP_YieldByReference: @@ -2965,7 +2964,6 @@ getContextualNilDiagnostic(ContextualTypePurpose CTP) { case CTP_ForEachSequence: case CTP_YieldByReference: case CTP_WrappedProperty: - case CTP_ComposedPropertyWrapper: case CTP_ExprPattern: case CTP_SingleValueStmtBranch: return std::nullopt; @@ -3750,7 +3748,6 @@ ContextualFailure::getDiagnosticFor(ContextualTypePurpose context, case CTP_ThrowStmt: case CTP_ForEachSequence: - case CTP_ComposedPropertyWrapper: case CTP_Unused: case CTP_CannotFail: case CTP_YieldByReference: diff --git a/lib/Sema/CSSimplify.cpp b/lib/Sema/CSSimplify.cpp index c1e40a1568f8a..e86f2eb46db44 100644 --- a/lib/Sema/CSSimplify.cpp +++ b/lib/Sema/CSSimplify.cpp @@ -16711,7 +16711,6 @@ void ConstraintSystem::addContextualConversionConstraint( case CTP_CoerceOperand: case CTP_SubscriptAssignSource: case CTP_WrappedProperty: - case CTP_ComposedPropertyWrapper: case CTP_ExprPattern: case CTP_SingleValueStmtBranch: break; diff --git a/lib/Sema/SyntacticElementTarget.cpp b/lib/Sema/SyntacticElementTarget.cpp index 88c3daec0a0c4..81785e207a0d7 100644 --- a/lib/Sema/SyntacticElementTarget.cpp +++ b/lib/Sema/SyntacticElementTarget.cpp @@ -273,7 +273,6 @@ bool SyntacticElementTarget::contextualTypeIsOnlyAHint() const { case CTP_SubscriptAssignSource: case CTP_Condition: case CTP_WrappedProperty: - case CTP_ComposedPropertyWrapper: case CTP_CannotFail: case CTP_ExprPattern: case CTP_SingleValueStmtBranch: