@@ -3368,6 +3368,20 @@ namespace {
3368
3368
assert (!isa<ImplicitConversionExpr>(expr) &&
3369
3369
" ImplicitConversionExpr should be eliminated in walkToExprPre" );
3370
3370
3371
+ auto buildMemberRef = [&](Type memberType, Expr *base, SourceLoc dotLoc,
3372
+ ConcreteDeclRef member, DeclNameLoc memberLoc,
3373
+ bool implicit) -> Expr * {
3374
+ auto *memberRef = new (TC.Context )
3375
+ MemberRefExpr (base, dotLoc, member, memberLoc, implicit);
3376
+
3377
+ if (memberType) {
3378
+ memberRef->setType (memberType);
3379
+ return CS.cacheType (memberRef);
3380
+ }
3381
+
3382
+ return memberRef;
3383
+ };
3384
+
3371
3385
// A DotSyntaxCallExpr is a member reference that has already been
3372
3386
// type-checked down to a call; turn it back into an overloaded
3373
3387
// member reference expression.
@@ -3377,21 +3391,23 @@ namespace {
3377
3391
memberLoc);
3378
3392
if (memberAndFunctionRef.first ) {
3379
3393
assert (!isa<ImplicitConversionExpr>(dotCall->getBase ()));
3380
- return new (TC.Context ) MemberRefExpr (dotCall->getBase (),
3381
- dotCall->getDotLoc (),
3382
- memberAndFunctionRef.first ,
3383
- memberLoc, expr->isImplicit ());
3394
+ return buildMemberRef (dotCall->getType (),
3395
+ dotCall->getBase (),
3396
+ dotCall->getDotLoc (),
3397
+ memberAndFunctionRef.first ,
3398
+ memberLoc, expr->isImplicit ());
3384
3399
}
3385
3400
}
3386
3401
3387
3402
if (auto *dynamicMember = dyn_cast<DynamicMemberRefExpr>(expr)) {
3388
3403
if (auto memberRef = dynamicMember->getMember ()) {
3389
3404
assert (!isa<ImplicitConversionExpr>(dynamicMember->getBase ()));
3390
- return new (TC.Context ) MemberRefExpr (dynamicMember->getBase (),
3391
- dynamicMember->getDotLoc (),
3392
- memberRef,
3393
- dynamicMember->getNameLoc (),
3394
- expr->isImplicit ());
3405
+ return buildMemberRef (dynamicMember->getType (),
3406
+ dynamicMember->getBase (),
3407
+ dynamicMember->getDotLoc (),
3408
+ memberRef,
3409
+ dynamicMember->getNameLoc (),
3410
+ expr->isImplicit ());
3395
3411
}
3396
3412
}
3397
3413
@@ -3405,10 +3421,11 @@ namespace {
3405
3421
memberLoc);
3406
3422
if (memberAndFunctionRef.first ) {
3407
3423
assert (!isa<ImplicitConversionExpr>(dotIgnored->getLHS ()));
3408
- return new (TC.Context ) MemberRefExpr (dotIgnored->getLHS (),
3409
- dotIgnored->getDotLoc (),
3410
- memberAndFunctionRef.first ,
3411
- memberLoc, expr->isImplicit ());
3424
+ return buildMemberRef (dotIgnored->getType (),
3425
+ dotIgnored->getLHS (),
3426
+ dotIgnored->getDotLoc (),
3427
+ memberAndFunctionRef.first ,
3428
+ memberLoc, expr->isImplicit ());
3412
3429
}
3413
3430
}
3414
3431
return expr;
0 commit comments