@@ -1149,8 +1149,11 @@ class SolutionApplicationTarget {
1149
1149
struct {
1150
1150
Expr *expression;
1151
1151
1152
+ // / The purpose of the contextual type.
1153
+ ContextualTypePurpose contextualPurpose;
1154
+
1152
1155
// / The type to which the expression should be converted.
1153
- Type convertType;
1156
+ TypeLoc convertType;
1154
1157
1155
1158
// / Whether the expression result will be discarded at the end.
1156
1159
bool isDiscarded;
@@ -1163,9 +1166,18 @@ class SolutionApplicationTarget {
1163
1166
};
1164
1167
1165
1168
public:
1166
- SolutionApplicationTarget (Expr *expr, Type convertType, bool isDiscarded) {
1169
+ SolutionApplicationTarget (Expr *expr,
1170
+ ContextualTypePurpose contextualPurpose,
1171
+ Type convertType, bool isDiscarded)
1172
+ : SolutionApplicationTarget(expr, contextualPurpose,
1173
+ TypeLoc::withoutLoc (convertType),
1174
+ isDiscarded) { }
1175
+
1176
+ SolutionApplicationTarget (Expr *expr, ContextualTypePurpose contextualPurpose,
1177
+ TypeLoc convertType, bool isDiscarded) {
1167
1178
kind = Kind::expression;
1168
1179
expression.expression = expr;
1180
+ expression.contextualPurpose = contextualPurpose;
1169
1181
expression.convertType = convertType;
1170
1182
expression.isDiscarded = isDiscarded;
1171
1183
}
@@ -1189,16 +1201,31 @@ class SolutionApplicationTarget {
1189
1201
}
1190
1202
}
1191
1203
1204
+ ContextualTypePurpose getExprContextualTypePurpose () const {
1205
+ assert (kind == Kind::expression);
1206
+ return expression.contextualPurpose ;
1207
+ }
1208
+
1192
1209
Type getExprConversionType () const {
1210
+ assert (kind == Kind::expression);
1211
+ return expression.convertType .getType ();
1212
+ }
1213
+
1214
+ TypeLoc getExprConversionTypeLoc () const {
1193
1215
assert (kind == Kind::expression);
1194
1216
return expression.convertType ;
1195
1217
}
1196
1218
1197
1219
void setExprConversionType (Type type) {
1220
+ assert (kind == Kind::expression);
1221
+ expression.convertType = TypeLoc::withoutLoc (type);
1222
+ }
1223
+
1224
+ void setExprConversionTypeLoc (TypeLoc type) {
1198
1225
assert (kind == Kind::expression);
1199
1226
expression.convertType = type;
1200
1227
}
1201
-
1228
+
1202
1229
bool isDiscardedExpr () const {
1203
1230
assert (kind == Kind::expression);
1204
1231
return expression.isDiscarded ;
0 commit comments