@@ -381,14 +381,15 @@ static Expr *buildDynamicMemberLookupIndexExpr(StringRef name, Type ty,
381
381
// Build and type check the string literal index value to the specific
382
382
// string type expected by the subscript.
383
383
Expr *nameExpr = new (ctx) StringLiteralExpr (name, loc, /* implicit*/ true );
384
+ (void )cs.TC .typeCheckExpression (nameExpr, dc);
385
+ cs.cacheExprTypes (nameExpr);
384
386
385
387
// Build a tuple so that the argument has a label.
386
388
Expr *tuple = TupleExpr::create (ctx, loc, nameExpr, ctx.Id_dynamicMember ,
387
389
loc, loc, /* hasTrailingClosure*/ false ,
388
390
/* implicit*/ true );
389
- (void )cs.TC .typeCheckExpression (tuple, dc, TypeLoc::withoutLoc (ty),
390
- CTP_CallArgument);
391
- cs.cacheExprTypes (tuple);
391
+ cs.setType (tuple, ty);
392
+ tuple->setType (ty);
392
393
return tuple;
393
394
}
394
395
@@ -4419,13 +4420,17 @@ namespace {
4419
4420
auto loc = origComponent.getLoc ();
4420
4421
auto fieldName =
4421
4422
foundDecl->choice .getName ().getBaseIdentifier ().str ();
4422
- auto index = buildDynamicMemberLookupIndexExpr (fieldName, indexType,
4423
- loc, dc, cs);
4424
-
4423
+
4424
+ Expr *nameExpr = new (ctx) StringLiteralExpr (fieldName, loc,
4425
+ /* implicit*/ true );
4426
+ (void )cs.TC .typeCheckExpression (nameExpr, dc);
4427
+ cs.cacheExprTypes (nameExpr);
4428
+
4425
4429
origComponent = KeyPathExpr::Component::
4426
- forUnresolvedSubscript (ctx, loc, index, {}, loc, loc,
4427
- /* trailingClosure*/ nullptr );
4428
- cs.setType (origComponent.getIndexExpr (), index->getType ());
4430
+ forUnresolvedSubscript (ctx, loc,
4431
+ {nameExpr}, {ctx.Id_dynamicMember }, {loc},
4432
+ loc, /* trailingClosure*/ nullptr );
4433
+ cs.setType (origComponent.getIndexExpr (), indexType);
4429
4434
}
4430
4435
4431
4436
auto subscriptType =
0 commit comments