mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #30022 from LucianoPAlmeida/SR-9839-convention-function-conversions-fail
[SR-9839] Fixes ambiguity in convention function argument inference
This commit is contained in:
@@ -2770,14 +2770,22 @@ static bool diagnoseConflictingGenericArguments(ConstraintSystem &cs,
|
||||
if (!diff.overloads.empty())
|
||||
return false;
|
||||
|
||||
if (!llvm::all_of(solutions, [](const Solution &solution) -> bool {
|
||||
bool noFixes = llvm::all_of(solutions, [](const Solution &solution) -> bool {
|
||||
const auto score = solution.getFixedScore();
|
||||
return score.Data[SK_Fix] == 0 && solution.Fixes.empty();
|
||||
});
|
||||
|
||||
bool allMismatches =
|
||||
llvm::all_of(solutions, [](const Solution &solution) -> bool {
|
||||
return llvm::all_of(
|
||||
solution.Fixes, [](const ConstraintFix *fix) -> bool {
|
||||
return fix->getKind() == FixKind::AllowArgumentTypeMismatch ||
|
||||
fix->getKind() == FixKind::AllowFunctionTypeMismatch ||
|
||||
fix->getKind() == FixKind::AllowTupleTypeMismatch;
|
||||
});
|
||||
}))
|
||||
});
|
||||
|
||||
if (!noFixes && !allMismatches)
|
||||
return false;
|
||||
|
||||
auto &DE = cs.getASTContext().Diags;
|
||||
@@ -2930,6 +2938,11 @@ bool ConstraintSystem::diagnoseAmbiguityWithFixes(
|
||||
if (solutions.empty())
|
||||
return false;
|
||||
|
||||
SolutionDiff solutionDiff(solutions);
|
||||
|
||||
if (diagnoseConflictingGenericArguments(*this, solutionDiff, solutions))
|
||||
return true;
|
||||
|
||||
if (auto bestScore = solverState->BestScore) {
|
||||
solutions.erase(llvm::remove_if(solutions,
|
||||
[&](const Solution &solution) {
|
||||
@@ -2945,11 +2958,6 @@ bool ConstraintSystem::diagnoseAmbiguityWithFixes(
|
||||
return false;
|
||||
}
|
||||
|
||||
SolutionDiff solutionDiff(solutions);
|
||||
|
||||
if (diagnoseConflictingGenericArguments(*this, solutionDiff, solutions))
|
||||
return true;
|
||||
|
||||
if (diagnoseAmbiguityWithEphemeralPointers(*this, solutions))
|
||||
return true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user