Skip to content

Commit f26bce3

Browse files
committed
[Sema] NFC: Move ContextualTypePurpose to constraint system header
1 parent 161899d commit f26bce3

File tree

2 files changed

+40
-42
lines changed

2 files changed

+40
-42
lines changed

lib/Sema/ConstraintSystem.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,46 @@ void *operator new(size_t bytes, swift::constraints::ConstraintSystem& cs,
6666

6767
namespace swift {
6868

69+
/// This specifies the purpose of the contextual type, when specified to
70+
/// typeCheckExpression. This is used for diagnostic generation to produce more
71+
/// specified error messages when the conversion fails.
72+
///
73+
enum ContextualTypePurpose {
74+
CTP_Unused, ///< No contextual type is specified.
75+
CTP_Initialization, ///< Pattern binding initialization.
76+
CTP_ReturnStmt, ///< Value specified to a 'return' statement.
77+
CTP_ReturnSingleExpr, ///< Value implicitly returned from a function.
78+
CTP_YieldByValue, ///< By-value yield operand.
79+
CTP_YieldByReference, ///< By-reference yield operand.
80+
CTP_ThrowStmt, ///< Value specified to a 'throw' statement.
81+
CTP_EnumCaseRawValue, ///< Raw value specified for "case X = 42" in enum.
82+
CTP_DefaultParameter, ///< Default value in parameter 'foo(a : Int = 42)'.
83+
84+
/// Default value in @autoclosure parameter
85+
/// 'foo(a : @autoclosure () -> Int = 42)'.
86+
CTP_AutoclosureDefaultParameter,
87+
88+
CTP_CalleeResult, ///< Constraint is placed on the result of a callee.
89+
CTP_CallArgument, ///< Call to function or operator requires type.
90+
CTP_ClosureResult, ///< Closure result expects a specific type.
91+
CTP_ArrayElement, ///< ArrayExpr wants elements to have a specific type.
92+
CTP_DictionaryKey, ///< DictionaryExpr keys should have a specific type.
93+
CTP_DictionaryValue, ///< DictionaryExpr values should have a specific type.
94+
CTP_CoerceOperand, ///< CoerceExpr operand coerced to specific type.
95+
CTP_AssignSource, ///< AssignExpr source operand coerced to result type.
96+
CTP_SubscriptAssignSource, ///< AssignExpr source operand coerced to subscript
97+
///< result type.
98+
CTP_Condition, ///< Condition expression of various statements e.g.
99+
///< `if`, `for`, `while` etc.
100+
CTP_ForEachStmt, ///< "expression/sequence" associated with 'for-in' loop
101+
///< is expected to conform to 'Sequence' protocol.
102+
CTP_WrappedProperty, ///< Property type expected to match 'wrappedValue' type
103+
CTP_ComposedPropertyWrapper, ///< Composed wrapper type expected to match
104+
///< former 'wrappedValue' type
105+
106+
CTP_CannotFail, ///< Conversion can never fail. abort() if it does.
107+
};
108+
69109
namespace constraints {
70110

71111
/// Describes the algorithm to use for trailing closure matching.

lib/Sema/TypeChecker.h

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -112,48 +112,6 @@ class LookupTypeResult {
112112
}
113113
};
114114

115-
/// This specifies the purpose of the contextual type, when specified to
116-
/// typeCheckExpression. This is used for diagnostic generation to produce more
117-
/// specified error messages when the conversion fails.
118-
///
119-
enum ContextualTypePurpose {
120-
CTP_Unused, ///< No contextual type is specified.
121-
CTP_Initialization, ///< Pattern binding initialization.
122-
CTP_ReturnStmt, ///< Value specified to a 'return' statement.
123-
CTP_ReturnSingleExpr, ///< Value implicitly returned from a function.
124-
CTP_YieldByValue, ///< By-value yield operand.
125-
CTP_YieldByReference, ///< By-reference yield operand.
126-
CTP_ThrowStmt, ///< Value specified to a 'throw' statement.
127-
CTP_EnumCaseRawValue, ///< Raw value specified for "case X = 42" in enum.
128-
CTP_DefaultParameter, ///< Default value in parameter 'foo(a : Int = 42)'.
129-
130-
/// Default value in @autoclosure parameter
131-
/// 'foo(a : @autoclosure () -> Int = 42)'.
132-
CTP_AutoclosureDefaultParameter,
133-
134-
CTP_CalleeResult, ///< Constraint is placed on the result of a callee.
135-
CTP_CallArgument, ///< Call to function or operator requires type.
136-
CTP_ClosureResult, ///< Closure result expects a specific type.
137-
CTP_ArrayElement, ///< ArrayExpr wants elements to have a specific type.
138-
CTP_DictionaryKey, ///< DictionaryExpr keys should have a specific type.
139-
CTP_DictionaryValue, ///< DictionaryExpr values should have a specific type.
140-
CTP_CoerceOperand, ///< CoerceExpr operand coerced to specific type.
141-
CTP_AssignSource, ///< AssignExpr source operand coerced to result type.
142-
CTP_SubscriptAssignSource, ///< AssignExpr source operand coerced to subscript
143-
///< result type.
144-
CTP_Condition, ///< Condition expression of various statements e.g.
145-
///< `if`, `for`, `while` etc.
146-
CTP_ForEachStmt, ///< "expression/sequence" associated with 'for-in' loop
147-
///< is expected to conform to 'Sequence' protocol.
148-
CTP_WrappedProperty, ///< Property type expected to match 'wrappedValue' type
149-
CTP_ComposedPropertyWrapper, ///< Composed wrapper type expected to match
150-
///< former 'wrappedValue' type
151-
152-
CTP_CannotFail, ///< Conversion can never fail. abort() if it does.
153-
};
154-
155-
156-
157115
/// Flags that can be used to control type checking.
158116
enum class TypeCheckExprFlags {
159117
/// Whether we know that the result of the expression is discarded. This

0 commit comments

Comments
 (0)