@@ -4828,10 +4828,10 @@ Type ConstraintSystem::simplifyAppliedOverloads(
4828
4828
if (!disjunction) return fnType;
4829
4829
4830
4830
// / The common result type amongst all function overloads.
4831
- Optional< Type> commonResultType;
4831
+ Type commonResultType;
4832
4832
auto updateCommonResultType = [&](Type choiceType) {
4833
4833
auto markFailure = [&] {
4834
- commonResultType = Type ( );
4834
+ commonResultType = ErrorType::get ( getASTContext () );
4835
4835
};
4836
4836
4837
4837
auto choiceFnType = choiceType->getAs <FunctionType>();
@@ -4850,12 +4850,8 @@ Type ConstraintSystem::simplifyAppliedOverloads(
4850
4850
return ;
4851
4851
}
4852
4852
4853
- // If we already failed, we're done.
4854
- if (commonResultType->isNull ())
4855
- return ;
4856
-
4857
4853
// If we found something different, fail.
4858
- if (!commonResultType. getValue () ->isEqual (choiceResultType))
4854
+ if (!commonResultType->isEqual (choiceResultType))
4859
4855
return markFailure ();
4860
4856
};
4861
4857
@@ -4919,19 +4915,19 @@ Type ConstraintSystem::simplifyAppliedOverloads(
4919
4915
return fnType;
4920
4916
4921
4917
// If we have a common result type, bind the expected result type to it.
4922
- if (commonResultType && * commonResultType) {
4918
+ if (commonResultType && ! commonResultType-> is <ErrorType>() ) {
4923
4919
ASTContext &ctx = getASTContext ();
4924
4920
if (ctx.LangOpts .DebugConstraintSolver ) {
4925
4921
auto &log = ctx.TypeCheckerDebug ->getStream ();
4926
4922
log.indent (solverState ? solverState->depth * 2 + 2 : 0 )
4927
4923
<< " (common result type for $T" << fnTypeVar->getID () << " is "
4928
- << commonResultType-> getString ()
4924
+ << commonResultType. getString ()
4929
4925
<< " )\n " ;
4930
4926
}
4931
4927
4932
4928
// FIXME: Could also rewrite fnType to include this result type.
4933
4929
addConstraint (ConstraintKind::Bind, argFnType->getResult (),
4934
- * commonResultType, locator);
4930
+ commonResultType, locator);
4935
4931
}
4936
4932
4937
4933
return fnType;
0 commit comments