Skip to content

Commit aa3e2d5

Browse files
committed
[CS] Stop passing FunctionRefKind in a couple of places
We can retrieve it from the passed OverloadChoice.
1 parent 01f46b3 commit aa3e2d5

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

lib/Sema/CSApply.cpp

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,6 @@ namespace {
386386
/// Build a reference to the given declaration.
387387
Expr *buildDeclRef(OverloadChoice choice, DeclNameLoc loc, Type openedType,
388388
ConstraintLocatorBuilder locator, bool implicit,
389-
FunctionRefKind functionRefKind,
390389
AccessSemantics semantics) {
391390
assert(choice.getKind() != OverloadChoiceKind::DeclViaDynamic);
392391
auto *decl = choice.getDecl();
@@ -435,7 +434,7 @@ namespace {
435434
} else {
436435
auto declRefExpr = new (ctx) DeclRefExpr(witness, loc,
437436
/*Implicit=*/false);
438-
declRefExpr->setFunctionRefKind(functionRefKind);
437+
declRefExpr->setFunctionRefKind(choice.getFunctionRefKind());
439438
refExpr = declRefExpr;
440439
}
441440

@@ -466,7 +465,7 @@ namespace {
466465

467466
return buildMemberRef(base, openedType, SourceLoc(), choice, loc,
468467
openedFnType->getResult(), locator, locator,
469-
implicit, functionRefKind, semantics);
468+
implicit, semantics);
470469
}
471470

472471
auto type = solution.simplifyType(openedType);
@@ -483,7 +482,7 @@ namespace {
483482
auto declRefExpr =
484483
new (ctx) DeclRefExpr(ref, loc, implicit, semantics, type);
485484
cs.cacheType(declRefExpr);
486-
declRefExpr->setFunctionRefKind(functionRefKind);
485+
declRefExpr->setFunctionRefKind(choice.getFunctionRefKind());
487486
return forceUnwrapIfExpected(declRefExpr, choice, locator);
488487
}
489488

@@ -738,7 +737,6 @@ namespace {
738737
OverloadChoice choice, DeclNameLoc memberLoc,
739738
Type openedType, ConstraintLocatorBuilder locator,
740739
ConstraintLocatorBuilder memberLocator, bool Implicit,
741-
FunctionRefKind functionRefKind,
742740
AccessSemantics semantics) {
743741
ValueDecl *member = choice.getDecl();
744742

@@ -770,7 +768,7 @@ namespace {
770768
"Direct property access doesn't make sense for this");
771769
auto ref = new (context) DeclRefExpr(memberRef, memberLoc, Implicit);
772770
cs.setType(ref, refTy);
773-
ref->setFunctionRefKind(functionRefKind);
771+
ref->setFunctionRefKind(choice.getFunctionRefKind());
774772
auto *DSBI = cs.cacheType(new (context) DotSyntaxBaseIgnoredExpr(
775773
base, dotLoc, ref, cs.getType(ref)));
776774
return forceUnwrapIfExpected(DSBI, choice, memberLocator);
@@ -969,7 +967,7 @@ namespace {
969967
// Handle all other references.
970968
auto declRefExpr = new (context) DeclRefExpr(memberRef, memberLoc,
971969
Implicit, semantics);
972-
declRefExpr->setFunctionRefKind(functionRefKind);
970+
declRefExpr->setFunctionRefKind(choice.getFunctionRefKind());
973971
cs.setType(declRefExpr, refTy);
974972
Expr *ref = declRefExpr;
975973

@@ -2275,7 +2273,6 @@ namespace {
22752273

22762274
return buildDeclRef(selected->choice, expr->getNameLoc(),
22772275
selected->openedFullType, locator, expr->isImplicit(),
2278-
expr->getFunctionRefKind(),
22792276
expr->getAccessSemantics());
22802277
}
22812278

@@ -2308,7 +2305,6 @@ namespace {
23082305

23092306
return buildDeclRef(choice, expr->getNameLoc(), selected.openedFullType,
23102307
locator, expr->isImplicit(),
2311-
choice.getFunctionRefKind(),
23122308
AccessSemantics::Ordinary);
23132309
}
23142310

@@ -2331,7 +2327,7 @@ namespace {
23312327
expr->getBase(), selected.openedFullType, expr->getDotLoc(),
23322328
selected.choice, expr->getNameLoc(), selected.openedType,
23332329
cs.getConstraintLocator(expr), memberLocator, expr->isImplicit(),
2334-
selected.choice.getFunctionRefKind(), expr->getAccessSemantics());
2330+
expr->getAccessSemantics());
23352331
}
23362332

23372333
Expr *visitDynamicMemberRefExpr(DynamicMemberRefExpr *expr) {
@@ -2376,7 +2372,7 @@ namespace {
23762372
base, selected.openedFullType, expr->getDotLoc(), selected.choice,
23772373
expr->getNameLoc(), selected.openedType,
23782374
exprLoc, memberLocator, expr->isImplicit(),
2379-
selected.choice.getFunctionRefKind(), AccessSemantics::Ordinary);
2375+
AccessSemantics::Ordinary);
23802376
if (!result)
23812377
return nullptr;
23822378

@@ -2515,8 +2511,7 @@ namespace {
25152511
Expr *applyCtorRefExpr(Expr *expr, Expr *base, SourceLoc dotLoc,
25162512
DeclNameLoc nameLoc, bool implicit,
25172513
ConstraintLocator *ctorLocator,
2518-
OverloadChoice choice,
2519-
FunctionRefKind functionRefKind, Type openedType) {
2514+
OverloadChoice choice, Type openedType) {
25202515
assert(choice.getKind() != OverloadChoiceKind::DeclViaDynamic);
25212516
auto *ctor = cast<ConstructorDecl>(choice.getDecl());
25222517

@@ -2526,7 +2521,7 @@ namespace {
25262521
return buildMemberRef(
25272522
base, openedType, dotLoc, choice, nameLoc, cs.getType(expr),
25282523
ConstraintLocatorBuilder(cs.getConstraintLocator(expr)),
2529-
ctorLocator, implicit, functionRefKind, AccessSemantics::Ordinary);
2524+
ctorLocator, implicit, AccessSemantics::Ordinary);
25302525
}
25312526

25322527
// The subexpression must be either 'self' or 'super'.
@@ -2590,7 +2585,7 @@ namespace {
25902585
auto choice = selected->choice;
25912586
return applyCtorRefExpr(
25922587
expr, base, dotLoc, nameLoc, implicit, ctorLocator, choice,
2593-
choice.getFunctionRefKind(), selected->openedFullType);
2588+
selected->openedFullType);
25942589
}
25952590

25962591
// Determine the declaration selected for this overloaded reference.
@@ -2620,7 +2615,6 @@ namespace {
26202615

26212616
return buildDeclRef(selected.choice, nameLoc, selected.openedFullType,
26222617
memberLocator, implicit,
2623-
selected.choice.getFunctionRefKind(),
26242618
AccessSemantics::Ordinary);
26252619
}
26262620

@@ -2654,8 +2648,7 @@ namespace {
26542648
return buildMemberRef(base, selected.openedFullType, dotLoc,
26552649
selected.choice, nameLoc, selected.openedType,
26562650
cs.getConstraintLocator(expr), memberLocator,
2657-
implicit, selected.choice.getFunctionRefKind(),
2658-
AccessSemantics::Ordinary);
2651+
implicit, AccessSemantics::Ordinary);
26592652

26602653
case OverloadChoiceKind::TupleIndex: {
26612654
Type toType = simplifyType(cs.getType(expr));
@@ -6490,8 +6483,7 @@ static Expr *buildCallAsFunctionMethodRef(
64906483
auto *declRef = rewriter.buildMemberRef(
64916484
fn, selected.openedFullType, /*dotLoc*/ SourceLoc(), choice,
64926485
DeclNameLoc(fn->getEndLoc()), selected.openedType, applyFunctionLoc,
6493-
applyFunctionLoc, /*implicit*/ true, choice.getFunctionRefKind(),
6494-
AccessSemantics::Ordinary);
6486+
applyFunctionLoc, /*implicit*/ true, AccessSemantics::Ordinary);
64956487
if (!declRef)
64966488
return nullptr;
64976489
declRef->setImplicit(apply->isImplicit());
@@ -6527,7 +6519,6 @@ ExprRewriter::finishApplyDynamicCallable(ApplyExpr *apply,
65276519
SourceLoc(), selected.choice,
65286520
DeclNameLoc(method->getNameLoc()),
65296521
selected.openedType, loc, loc, /*implicit*/ true,
6530-
selected.choice.getFunctionRefKind(),
65316522
AccessSemantics::Ordinary);
65326523

65336524
// Construct argument to the method (either an array or dictionary
@@ -6888,7 +6879,6 @@ Expr *ExprRewriter::finishApply(ApplyExpr *apply, ConcreteDeclRef callee,
68886879
DeclNameLoc(fn->getEndLoc()),
68896880
selected->openedType, locator, ctorLocator,
68906881
/*Implicit=*/true,
6891-
choice.getFunctionRefKind(),
68926882
AccessSemantics::Ordinary);
68936883
if (!declRef)
68946884
return nullptr;

0 commit comments

Comments
 (0)