Skip to content

Commit 33b58d2

Browse files
committed
[CS] NFC: Factor out Solution::hasAppliedSelf
1 parent 8a689bb commit 33b58d2

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6093,6 +6093,7 @@ bool isAutoClosureArgument(Expr *argExpr);
60936093
/// parameter being applied, meaning that it's dropped from the type of the
60946094
/// reference.
60956095
bool hasAppliedSelf(ConstraintSystem &cs, const OverloadChoice &choice);
6096+
bool hasAppliedSelf(const Solution &S, const OverloadChoice &choice);
60966097
bool hasAppliedSelf(const OverloadChoice &choice,
60976098
llvm::function_ref<Type(Type)> getFixedType);
60986099

lib/Sema/CSDiagnostics.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2831,10 +2831,7 @@ bool ContextualFailure::diagnoseAsError() {
28312831
auto params = fnType->getParams();
28322832

28332833
ParameterListInfo info(
2834-
params, choice,
2835-
hasAppliedSelf(overload->choice, [&solution](Type type) {
2836-
return solution.simplifyType(type);
2837-
}));
2834+
params, choice, hasAppliedSelf(solution, overload->choice));
28382835
auto numMissingArgs = llvm::count_if(
28392836
indices(params), [&info](const unsigned paramIdx) -> bool {
28402837
return !info.hasDefaultArgument(paramIdx);

lib/Sema/ConstraintSystem.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3891,6 +3891,13 @@ bool constraints::hasAppliedSelf(ConstraintSystem &cs,
38913891
});
38923892
}
38933893

3894+
bool constraints::hasAppliedSelf(const Solution &S,
3895+
const OverloadChoice &choice) {
3896+
return hasAppliedSelf(choice, [&](Type type) -> Type {
3897+
return S.simplifyType(type);
3898+
});
3899+
}
3900+
38943901
bool constraints::hasAppliedSelf(const OverloadChoice &choice,
38953902
llvm::function_ref<Type(Type)> getFixedType) {
38963903
auto *decl = choice.getDeclOrNull();
@@ -4206,8 +4213,7 @@ Solution::getFunctionArgApplyInfo(ConstraintLocator *locator) const {
42064213
fnInterfaceType = callee->getInterfaceType();
42074214

42084215
// Strip off the curried self parameter if necessary.
4209-
if (hasAppliedSelf(
4210-
*choice, [this](Type type) -> Type { return simplifyType(type); }))
4216+
if (hasAppliedSelf(*this, *choice))
42114217
fnInterfaceType = fnInterfaceType->castTo<AnyFunctionType>()->getResult();
42124218

42134219
#ifndef NDEBUG

0 commit comments

Comments
 (0)