Skip to content

Commit 52cf601

Browse files
committed
[Diagnostics] Switch isMisplacedMissingArgument to use a solution
1 parent 0fc9d1b commit 52cf601

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4193,28 +4193,30 @@ bool MissingArgumentsFailure::isPropertyWrapperInitialization() const {
41934193

41944194
bool MissingArgumentsFailure::isMisplacedMissingArgument(
41954195
const Solution &solution, ConstraintLocator *locator) {
4196-
auto *calleeLocator = cs.getCalleeLocator(locator);
4197-
auto overloadChoice = cs.findSelectedOverloadFor(calleeLocator);
4196+
auto *calleeLocator = solution.getCalleeLocator(locator);
4197+
auto overloadChoice = solution.getOverloadChoiceIfAvailable(calleeLocator);
41984198
if (!overloadChoice)
41994199
return false;
42004200

4201-
auto *fnType = resolveType(overloadChoice->openedType)->getAs<FunctionType>();
4201+
auto *fnType =
4202+
solution.simplifyType(overloadChoice->openedType)->getAs<FunctionType>();
42024203
if (!(fnType && fnType->getNumParams() == 2))
42034204
return false;
42044205

42054206
auto *anchor = locator->getAnchor();
42064207

42074208
auto hasFixFor = [&](FixKind kind, ConstraintLocator *locator) -> bool {
4208-
auto fix = llvm::find_if(cs.getFixes(), [&](const ConstraintFix *fix) {
4209+
auto fix = llvm::find_if(solution.Fixes, [&](const ConstraintFix *fix) {
42094210
return fix->getLocator() == locator;
42104211
});
42114212

4212-
if (fix == cs.getFixes().end())
4213+
if (fix == solution.Fixes.end())
42134214
return false;
42144215

42154216
return (*fix)->getKind() == kind;
42164217
};
42174218

4219+
auto &cs = solution.getConstraintSystem();
42184220
auto *callLocator =
42194221
cs.getConstraintLocator(anchor, ConstraintLocator::ApplyArgument);
42204222

@@ -4245,7 +4247,7 @@ bool MissingArgumentsFailure::isMisplacedMissingArgument(
42454247
argument = tuple->getElement(0);
42464248
}
42474249

4248-
auto argType = cs.simplifyType(cs.getType(argument));
4250+
auto argType = solution.simplifyType(solution.getType(argument));
42494251
auto paramType = fnType->getParams()[1].getPlainType();
42504252

42514253
return TypeChecker::isConvertibleTo(argType, paramType, cs.DC);
@@ -5602,7 +5604,8 @@ bool ArgumentMismatchFailure::diagnoseMisplacedMissingArgument() const {
56025604
auto &cs = getConstraintSystem();
56035605
auto *locator = getLocator();
56045606

5605-
if (!MissingArgumentsFailure::isMisplacedMissingArgument(cs, locator))
5607+
if (!MissingArgumentsFailure::isMisplacedMissingArgument(getSolution(),
5608+
locator))
56065609
return false;
56075610

56085611
auto *argType = cs.createTypeVariable(

0 commit comments

Comments
 (0)