@@ -11081,9 +11081,19 @@ bool ConstraintSystem::simplifyAppliedOverloadsImpl(
1108111081 return true;
1108211082 }
1108311083
11084- // If types lined up exactly, let's favor this overload choice.
11085- if (Type(argFnType)->isEqual(choiceType))
11086- constraint->setFavored();
11084+ // If types of arguments/parameters and result lined up exactly,
11085+ // let's favor this overload choice.
11086+ //
11087+ // Note this check ignores `ExtInfo` on purpose and only compares
11088+ // types, if there are overloads that differ only in effects then
11089+ // all of them are going to be considered and filtered as part of
11090+ // "favored" group after forming a valid partial solution.
11091+ if (auto *choiceFnType = choiceType->getAs<FunctionType>()) {
11092+ if (FunctionType::equalParams(argFnType->getParams(),
11093+ choiceFnType->getParams()) &&
11094+ argFnType->getResult()->isEqual(choiceFnType->getResult()))
11095+ constraint->setFavored();
11096+ }
1108711097
1108811098 // Account for any optional unwrapping/binding
1108911099 for (unsigned i : range(numOptionalUnwraps)) {
@@ -12442,28 +12452,26 @@ ConstraintSystem::simplifyRestrictedConstraintImpl(
1244212452 if (worseThanBestSolution())
1244312453 return SolutionKind::Error;
1244412454
12445- auto *conversionLoc = getConstraintLocator(
12446- /*anchor=*/ASTNode(), LocatorPathElt::ImplicitConversion( restriction) );
12455+ auto *conversionLoc =
12456+ getImplicitValueConversionLocator(locator, restriction);
1244712457
1244812458 auto *applicationLoc =
1244912459 getConstraintLocator(conversionLoc, ConstraintLocator::ApplyFunction);
1245012460
1245112461 auto *memberLoc = getConstraintLocator(
1245212462 applicationLoc, ConstraintLocator::ConstructorMember);
1245312463
12454- // Conversion has been already attempted for this direction
12455- // and constructor choice has been recorded.
12456- if (findSelectedOverloadFor(memberLoc))
12457- return SolutionKind::Solved;
12458-
1245912464 // Allocate a single argument info to cover all possible
1246012465 // Double <-> CGFloat conversion locations.
12461- if (!ArgumentLists.count(memberLoc)) {
12466+ auto *argumentsLoc =
12467+ getConstraintLocator(conversionLoc, ConstraintLocator::ApplyArgument);
12468+
12469+ if (!ArgumentLists.count(argumentsLoc)) {
1246212470 auto *argList = ArgumentList::createImplicit(
1246312471 getASTContext(), {Argument(SourceLoc(), Identifier(), nullptr)},
1246412472 /*firstTrailingClosureIndex=*/None,
1246512473 AllocationArena::ConstraintSolver);
12466- ArgumentLists.insert({memberLoc , argList});
12474+ ArgumentLists.insert({argumentsLoc , argList});
1246712475 }
1246812476
1246912477 auto *memberTypeLoc = getConstraintLocator(
0 commit comments