Replace bool parameter to TypeChecker::conformsToProtocol() with an option set.

NFC; we can extend this option set more readily later.

Swift SVN r27894
This commit is contained in:
Doug Gregor
2015-04-29 00:08:22 +00:00
parent 4d197dc5b2
commit a30ca2a60d
18 changed files with 107 additions and 60 deletions

View File

@@ -1817,7 +1817,8 @@ ConstraintSystem::matchTypes(Type type1, Type type2, TypeMatchKind kind,
// Bridging from an ErrorType to an Objective-C NSError.
auto errorType = TC.Context.getProtocol(KnownProtocolKind::_ErrorType);
if (TC.conformsToProtocol(type1, errorType, DC, /*expr*/ true))
if (TC.conformsToProtocol(type1, errorType, DC,
ConformanceCheckFlags::InExpression))
if (auto NSErrorTy = TC.getNSErrorType(DC))
if (type2->isEqual(NSErrorTy))
conversionsOrFixes.push_back(
@@ -2298,7 +2299,8 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
}
} else {
// Check whether this type conforms to the protocol.
if (TC.conformsToProtocol(type, protocol, DC, true))
if (TC.conformsToProtocol(type, protocol, DC,
ConformanceCheckFlags::InExpression))
return SolutionKind::Solved;
}
@@ -2637,7 +2639,8 @@ static Type getRawRepresentableValueType(TypeChecker &tc, DeclContext *dc,
return nullptr;
ProtocolConformance *conformance = nullptr;
if (!tc.conformsToProtocol(type, proto, dc, true, &conformance))
if (!tc.conformsToProtocol(type, proto, dc,
ConformanceCheckFlags::InExpression, &conformance))
return nullptr;
return tc.getWitnessType(type, proto, conformance, tc.Context.Id_RawValue,