[CS] NFC: Factor out Solution::hasAppliedSelf

This commit is contained in:
Hamish Knight
2025-07-17 22:49:18 +01:00
parent 8a689bb4d3
commit 33b58d25d8
3 changed files with 10 additions and 6 deletions

View File

@@ -3891,6 +3891,13 @@ bool constraints::hasAppliedSelf(ConstraintSystem &cs,
});
}
bool constraints::hasAppliedSelf(const Solution &S,
const OverloadChoice &choice) {
return hasAppliedSelf(choice, [&](Type type) -> Type {
return S.simplifyType(type);
});
}
bool constraints::hasAppliedSelf(const OverloadChoice &choice,
llvm::function_ref<Type(Type)> getFixedType) {
auto *decl = choice.getDeclOrNull();
@@ -4206,8 +4213,7 @@ Solution::getFunctionArgApplyInfo(ConstraintLocator *locator) const {
fnInterfaceType = callee->getInterfaceType();
// Strip off the curried self parameter if necessary.
if (hasAppliedSelf(
*choice, [this](Type type) -> Type { return simplifyType(type); }))
if (hasAppliedSelf(*this, *choice))
fnInterfaceType = fnInterfaceType->castTo<AnyFunctionType>()->getResult();
#ifndef NDEBUG