@@ -1227,19 +1227,15 @@ namespace {
12271227 Expr *coerceToType (Expr *expr, Type toType,
12281228 ConstraintLocatorBuilder locator,
12291229 Optional<Pattern*> typeFromPattern = None);
1230-
1231- using LevelTy = llvm::PointerEmbeddedInt<unsigned , 2 >;
1232-
1230+
12331231 // / \brief Coerce the given expression (which is the argument to a call) to
12341232 // / the given parameter type.
12351233 // /
12361234 // / This operation cannot fail.
12371235 // /
12381236 // / \param arg The argument expression.
12391237 // / \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.
12431239 // / \param argLabels The argument labels provided for the call.
12441240 // / \param hasTrailingClosure Whether the last argument is a trailing
12451241 // / closure.
@@ -1248,7 +1244,7 @@ namespace {
12481244 // / \returns the coerced expression, which will have type \c ToType.
12491245 Expr *
12501246 coerceCallArguments (Expr *arg, Type paramType,
1251- llvm::PointerUnion< ApplyExpr *, LevelTy> applyOrLevel ,
1247+ ApplyExpr *apply ,
12521248 ArrayRef<Identifier> argLabels,
12531249 bool hasTrailingClosure,
12541250 ConstraintLocatorBuilder locator);
@@ -1406,10 +1402,9 @@ namespace {
14061402 }
14071403
14081404 // 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));
14131408 if (!index)
14141409 return nullptr ;
14151410
@@ -5140,24 +5135,13 @@ static bool isReferenceToMetatypeMember(ConstraintSystem &cs, Expr *expr) {
51405135 return false ;
51415136}
51425137
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) {
51535140 // If we do not have a callee, return a level of 0.
51545141 if (!callee) {
51555142 return 0 ;
51565143 }
51575144
5158- // Determine the level based on the application itself.
5159- auto *apply = applyOrLevel.get <ApplyExpr *>();
5160-
51615145 // Only calls to members of types can have level > 0.
51625146 auto calleeDecl = callee.getDecl ();
51635147 if (!calleeDecl->getDeclContext ()->isTypeContext ()) {
@@ -5185,7 +5169,7 @@ static unsigned computeCallLevel(
51855169
51865170Expr *ExprRewriter::coerceCallArguments (
51875171 Expr *arg, Type paramType,
5188- llvm::PointerUnion< ApplyExpr *, LevelTy> applyOrLevel ,
5172+ ApplyExpr *apply ,
51895173 ArrayRef<Identifier> argLabels,
51905174 bool hasTrailingClosure,
51915175 ConstraintLocatorBuilder locator) {
@@ -5230,7 +5214,7 @@ Expr *ExprRewriter::coerceCallArguments(
52305214 findCalleeDeclRef (cs, solution, cs.getConstraintLocator (locator));
52315215
52325216 // Determine the level,
5233- unsigned level = computeCallLevel (cs, callee, applyOrLevel );
5217+ unsigned level = computeCallLevel (cs, callee, apply );
52345218
52355219 // Determine the parameter bindings.
52365220 auto params = decomposeParamType (paramType, callee.getDecl (), level);
0 commit comments