@@ -1227,19 +1227,15 @@ namespace {
1227
1227
Expr *coerceToType (Expr *expr, Type toType,
1228
1228
ConstraintLocatorBuilder locator,
1229
1229
Optional<Pattern*> typeFromPattern = None);
1230
-
1231
- using LevelTy = llvm::PointerEmbeddedInt<unsigned , 2 >;
1232
-
1230
+
1233
1231
// / \brief Coerce the given expression (which is the argument to a call) to
1234
1232
// / the given parameter type.
1235
1233
// /
1236
1234
// / This operation cannot fail.
1237
1235
// /
1238
1236
// / \param arg The argument expression.
1239
1237
// / \param paramType The parameter type.
1240
- // / \param applyOrLevel For function applications, the ApplyExpr that forms
1241
- // / the call. Otherwise, a specific level describing which parameter level
1242
- // / we're applying.
1238
+ // / \param apply The ApplyExpr that forms the call.
1243
1239
// / \param argLabels The argument labels provided for the call.
1244
1240
// / \param hasTrailingClosure Whether the last argument is a trailing
1245
1241
// / closure.
@@ -1248,7 +1244,7 @@ namespace {
1248
1244
// / \returns the coerced expression, which will have type \c ToType.
1249
1245
Expr *
1250
1246
coerceCallArguments (Expr *arg, Type paramType,
1251
- llvm::PointerUnion< ApplyExpr *, LevelTy> applyOrLevel ,
1247
+ ApplyExpr *apply ,
1252
1248
ArrayRef<Identifier> argLabels,
1253
1249
bool hasTrailingClosure,
1254
1250
ConstraintLocatorBuilder locator);
@@ -1406,10 +1402,9 @@ namespace {
1406
1402
}
1407
1403
1408
1404
// Coerce the index argument.
1409
- index = coerceCallArguments (
1410
- index, indexTy, LevelTy (1 ), argLabels,
1411
- hasTrailingClosure,
1412
- locator.withPathElement (ConstraintLocator::SubscriptIndex));
1405
+ index = coerceToType (index, indexTy,
1406
+ locator.withPathElement (
1407
+ ConstraintLocator::SubscriptIndex));
1413
1408
if (!index)
1414
1409
return nullptr ;
1415
1410
@@ -5140,24 +5135,13 @@ static bool isReferenceToMetatypeMember(ConstraintSystem &cs, Expr *expr) {
5140
5135
return false ;
5141
5136
}
5142
5137
5143
- static unsigned computeCallLevel (
5144
- ConstraintSystem &cs, ConcreteDeclRef callee,
5145
- llvm::PointerUnion<ApplyExpr *, ExprRewriter::LevelTy> applyOrLevel) {
5146
- using LevelTy = ExprRewriter::LevelTy;
5147
-
5148
- if (applyOrLevel.is <LevelTy>()) {
5149
- // Level specified by caller.
5150
- return applyOrLevel.get <LevelTy>();
5151
- }
5152
-
5138
+ static unsigned computeCallLevel (ConstraintSystem &cs, ConcreteDeclRef callee,
5139
+ ApplyExpr *apply) {
5153
5140
// If we do not have a callee, return a level of 0.
5154
5141
if (!callee) {
5155
5142
return 0 ;
5156
5143
}
5157
5144
5158
- // Determine the level based on the application itself.
5159
- auto *apply = applyOrLevel.get <ApplyExpr *>();
5160
-
5161
5145
// Only calls to members of types can have level > 0.
5162
5146
auto calleeDecl = callee.getDecl ();
5163
5147
if (!calleeDecl->getDeclContext ()->isTypeContext ()) {
@@ -5185,7 +5169,7 @@ static unsigned computeCallLevel(
5185
5169
5186
5170
Expr *ExprRewriter::coerceCallArguments (
5187
5171
Expr *arg, Type paramType,
5188
- llvm::PointerUnion< ApplyExpr *, LevelTy> applyOrLevel ,
5172
+ ApplyExpr *apply ,
5189
5173
ArrayRef<Identifier> argLabels,
5190
5174
bool hasTrailingClosure,
5191
5175
ConstraintLocatorBuilder locator) {
@@ -5230,7 +5214,7 @@ Expr *ExprRewriter::coerceCallArguments(
5230
5214
findCalleeDeclRef (cs, solution, cs.getConstraintLocator (locator));
5231
5215
5232
5216
// Determine the level,
5233
- unsigned level = computeCallLevel (cs, callee, applyOrLevel );
5217
+ unsigned level = computeCallLevel (cs, callee, apply );
5234
5218
5235
5219
// Determine the parameter bindings.
5236
5220
auto params = decomposeParamType (paramType, callee.getDecl (), level);
0 commit comments