Sema: More robust in the face of missing stdlib protocols

This came up with SourceKit fuzz testing on the stdlib. I don't have a
reduced testcase right now.

Progress on <rdar://problem/19554069>.

Swift SVN r30882
This commit is contained in:
Slava Pestov
2015-07-31 21:22:51 +00:00
parent 1ca56079f9
commit 20ff9df27f
3 changed files with 21 additions and 17 deletions

View File

@@ -1827,13 +1827,14 @@ 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.containsProtocol(type1, errorType, DC,
ConformanceCheckFlags::InExpression))
if (auto NSErrorTy = TC.getNSErrorType(DC))
if (type2->isEqual(NSErrorTy))
conversionsOrFixes.push_back(
ConversionRestrictionKind::BridgeToNSError);
if (auto errorType = TC.Context.getProtocol(KnownProtocolKind::ErrorType)) {
if (TC.containsProtocol(type1, errorType, DC,
ConformanceCheckFlags::InExpression))
if (auto NSErrorTy = TC.getNSErrorType(DC))
if (type2->isEqual(NSErrorTy))
conversionsOrFixes.push_back(
ConversionRestrictionKind::BridgeToNSError);
}
}
// Pointer arguments can be converted from pointer-compatible types.