Remove Boolean as a special, privileged type used by Sema, and instead

use the concrete Bool type.  This eliminates a bunch of complexity and
makes diagnostics more concrete.
This commit is contained in:
Chris Lattner
2016-07-17 15:13:25 -07:00
parent eec2765613
commit 55fbe5a763
23 changed files with 102 additions and 321 deletions

View File

@@ -2307,12 +2307,7 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
// See if there's anything we can do to fix the conformance:
OptionalTypeKind optionalKind;
if (auto optionalObjectType = type->getAnyOptionalObjectType(optionalKind)) {
if (protocol->isSpecificProtocol(KnownProtocolKind::Boolean)) {
// Optionals don't conform to Boolean; suggest '!= nil'.
if (recordFix(FixKind::OptionalToBoolean, getConstraintLocator(locator)))
return SolutionKind::Error;
return SolutionKind::Solved;
} else if (optionalKind == OTK_Optional) {
if (optionalKind == OTK_Optional) {
// The underlying type of an optional may conform to the protocol if the
// optional doesn't; suggest forcing if that's the case.
auto result = simplifyConformsToConstraint(
@@ -4231,10 +4226,6 @@ ConstraintSystem::simplifyFixConstraint(Fix fix, Type type1, Type type2,
return matchTypes(InOutType::get(type1->getRValueType()), type2,
matchKind, subFlags, locator);
case FixKind::OptionalToBoolean:
// The actual semantics are handled elsewhere.
return SolutionKind::Solved;
case FixKind::CoerceToCheckedCast:
llvm_unreachable("handled elsewhere");
}