Skip to content

Commit 7249c92

Browse files
committed
Use ErrorType as a sentinel type rather than Optional<Type>
1 parent a6902cc commit 7249c92

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4828,10 +4828,10 @@ Type ConstraintSystem::simplifyAppliedOverloads(
48284828
if (!disjunction) return fnType;
48294829

48304830
/// The common result type amongst all function overloads.
4831-
Optional<Type> commonResultType;
4831+
Type commonResultType;
48324832
auto updateCommonResultType = [&](Type choiceType) {
48334833
auto markFailure = [&] {
4834-
commonResultType = Type();
4834+
commonResultType = ErrorType::get(getASTContext());
48354835
};
48364836

48374837
auto choiceFnType = choiceType->getAs<FunctionType>();
@@ -4850,12 +4850,8 @@ Type ConstraintSystem::simplifyAppliedOverloads(
48504850
return;
48514851
}
48524852

4853-
// If we already failed, we're done.
4854-
if (commonResultType->isNull())
4855-
return;
4856-
48574853
// If we found something different, fail.
4858-
if (!commonResultType.getValue()->isEqual(choiceResultType))
4854+
if (!commonResultType->isEqual(choiceResultType))
48594855
return markFailure();
48604856
};
48614857

@@ -4919,19 +4915,19 @@ Type ConstraintSystem::simplifyAppliedOverloads(
49194915
return fnType;
49204916

49214917
// If we have a common result type, bind the expected result type to it.
4922-
if (commonResultType && *commonResultType) {
4918+
if (commonResultType && !commonResultType->is<ErrorType>()) {
49234919
ASTContext &ctx = getASTContext();
49244920
if (ctx.LangOpts.DebugConstraintSolver) {
49254921
auto &log = ctx.TypeCheckerDebug->getStream();
49264922
log.indent(solverState ? solverState->depth * 2 + 2 : 0)
49274923
<< "(common result type for $T" << fnTypeVar->getID() << " is "
4928-
<< commonResultType->getString()
4924+
<< commonResultType.getString()
49294925
<< ")\n";
49304926
}
49314927

49324928
// FIXME: Could also rewrite fnType to include this result type.
49334929
addConstraint(ConstraintKind::Bind, argFnType->getResult(),
4934-
*commonResultType, locator);
4930+
commonResultType, locator);
49354931
}
49364932

49374933
return fnType;

0 commit comments

Comments
 (0)