Skip to content

Commit 7fecda7

Browse files
committed
[ConstraintSystem] Don't infer common result type from disabled overload choices
1 parent 50f3104 commit 7fecda7

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10401,6 +10401,24 @@ bool ConstraintSystem::simplifyAppliedOverloadsImpl(
1040110401
}
1040210402
}
1040310403

10404+
// Disabled overloads need special handling depending mode.
10405+
if (constraint->isDisabled()) {
10406+
// In diagnostic mode, invalidate previous common result type if
10407+
// current overload choice has a fix to make sure that we produce
10408+
// the best diagnostics possible.
10409+
if (shouldAttemptFixes()) {
10410+
if (constraint->getFix())
10411+
commonResultType = ErrorType::get(getASTContext());
10412+
return true;
10413+
}
10414+
10415+
// In performance mode, let's skip the disabled overload choice
10416+
// and continue - this would make sure that common result type
10417+
// could be found if one exists among the overloads the solver
10418+
// is actually going to attempt.
10419+
return false;
10420+
}
10421+
1040410422
// Determine the type that this choice will have.
1040510423
Type choiceType = getEffectiveOverloadType(
1040610424
constraint->getLocator(), choice, /*allowMembers=*/true,

0 commit comments

Comments
 (0)