@@ -403,14 +403,15 @@ static Expr *buildDynamicMemberLookupIndexExpr(StringRef name, Type ty,
403
403
// Build and type check the string literal index value to the specific
404
404
// string type expected by the subscript.
405
405
Expr *nameExpr = new (ctx) StringLiteralExpr (name, loc, /* implicit*/ true );
406
+ (void )cs.TC .typeCheckExpression (nameExpr, dc);
407
+ cs.cacheExprTypes (nameExpr);
406
408
407
409
// Build a tuple so that the argument has a label.
408
410
Expr *tuple = TupleExpr::create (ctx, loc, nameExpr, ctx.Id_dynamicMember ,
409
411
loc, loc, /* hasTrailingClosure*/ false ,
410
412
/* implicit*/ true );
411
- (void )cs.TC .typeCheckExpression (tuple, dc, TypeLoc::withoutLoc (ty),
412
- CTP_CallArgument);
413
- cs.cacheExprTypes (tuple);
413
+ cs.setType (tuple, ty);
414
+ tuple->setType (ty);
414
415
return tuple;
415
416
}
416
417
@@ -4430,13 +4431,17 @@ namespace {
4430
4431
auto loc = origComponent.getLoc ();
4431
4432
auto fieldName =
4432
4433
foundDecl->choice .getName ().getBaseIdentifier ().str ();
4433
- auto index = buildDynamicMemberLookupIndexExpr (fieldName, indexType,
4434
- loc, dc, cs);
4435
-
4434
+
4435
+ Expr *nameExpr = new (ctx) StringLiteralExpr (fieldName, loc,
4436
+ /* implicit*/ true );
4437
+ (void )cs.TC .typeCheckExpression (nameExpr, dc);
4438
+ cs.cacheExprTypes (nameExpr);
4439
+
4436
4440
origComponent = KeyPathExpr::Component::
4437
- forUnresolvedSubscript (ctx, loc, index, {}, loc, loc,
4438
- /* trailingClosure*/ nullptr );
4439
- cs.setType (origComponent.getIndexExpr (), index->getType ());
4441
+ forUnresolvedSubscript (ctx, loc,
4442
+ {nameExpr}, {ctx.Id_dynamicMember }, {loc},
4443
+ loc, /* trailingClosure*/ nullptr );
4444
+ cs.setType (origComponent.getIndexExpr (), indexType);
4440
4445
}
4441
4446
4442
4447
auto subscriptType =
0 commit comments